本文整理汇总了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);
}