当前位置: 首页>>代码示例>>Java>>正文


Java Builder类代码示例

本文整理汇总了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);
    }
 
开发者ID:espertechinc,项目名称:esper,代码行数:67,代码来源:AMQPSink.java


注:本文中的com.rabbitmq.client.AMQP.BasicProperties.Builder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。