本文整理匯總了Java中com.rabbitmq.client.AMQP.BasicProperties.Builder類的典型用法代碼示例。如果您正苦於以下問題:Java Builder類的具體用法?Java Builder怎麽用?Java Builder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Builder類屬於com.rabbitmq.client.AMQP.BasicProperties包,在下文中一共展示了Builder類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onInput
import com.rabbitmq.client.AMQP.BasicProperties.Builder; //導入依賴的package包/類
public void onInput(Object event) {
ObjectToAMQPCollectorContext holder = collectorDataTL.get();
if (holder == null) {
if (settings.getExchange() != null && settings.getRoutingKey() != null) {
if (log.isDebugEnabled()) {
log.debug("Using exchange " + settings.getExchange() + " routing-key " + settings.getRoutingKey());
}
holder = new ObjectToAMQPCollectorContext(new AMQPEmitter() {
public void send(byte[] bytes) {
try {
channel.basicPublish(settings.getExchange(), settings.getRoutingKey(), null, bytes);
} catch (IOException e) {
String message = "Failed to publish to AMQP: " + e.getMessage();
log.error(message, e);
throw new RuntimeException(message, e);
}
}
public void send(byte[] bytes, Map<String, Object> headers) {
try {
Builder builder = new Builder();
channel.basicPublish(settings.getExchange(), settings.getRoutingKey(), builder.headers(headers).build(), bytes);
} catch (IOException e) {
String message = "Failed to publish to AMQP: " + e.getMessage();
log.error(message, e);
throw new RuntimeException(message, e);
}
}
}, event);
} else {
if (log.isDebugEnabled()) {
log.debug("Using queue " + settings.getQueueName());
}
holder = new ObjectToAMQPCollectorContext(new AMQPEmitter() {
public void send(byte[] bytes) {
try {
channel.basicPublish("", settings.getQueueName(), null, bytes);
} catch (IOException e) {
String message = "Failed to publish to AMQP: " + e.getMessage();
log.error(message, e);
throw new RuntimeException(message, e);
}
}
public void send(byte[] bytes, Map<String, Object> headers) {
try {
Builder builder = new Builder();
channel.basicPublish("", settings.getQueueName(), builder.headers(headers).build(), bytes);
} catch (IOException e) {
String message = "Failed to publish to AMQP: " + e.getMessage();
log.error(message, e);
throw new RuntimeException(message, e);
}
}
}, event);
}
collectorDataTL.set(holder);
} else {
holder.setObject(event);
}
settings.getCollector().collect(holder);
}