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


Java MQClientException.printStackTrace方法代码示例

本文整理汇总了Java中org.apache.rocketmq.client.exception.MQClientException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java MQClientException.printStackTrace方法的具体用法?Java MQClientException.printStackTrace怎么用?Java MQClientException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.rocketmq.client.exception.MQClientException的用法示例。


在下文中一共展示了MQClientException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: receiveBroadcastMessage

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
public void receiveBroadcastMessage(){
    DefaultMQPushConsumer consumer=new DefaultMQPushConsumer(RocketMQConfiguration.ROCKETMQ_GROUP);
    consumer.setNamesrvAddr(RocketMQConfiguration.ROCKETMQ_NAMESRV);
    consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
    consumer.setMessageModel(MessageModel.BROADCASTING);
    try {
        consumer.subscribe(RocketMQConfiguration.ROCKETMQ_TOPIC,"*");
        consumer.registerMessageListener(new MessageListenerConcurrently() {
            @Override
            public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext consumeConcurrentlyContext) {
                System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
                return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
            }
        });
        consumer.start();
    } catch (MQClientException e) {
        e.printStackTrace();
    }
}
 
开发者ID:mumudemo,项目名称:mumu-rocketmq,代码行数:20,代码来源:RocketMQBroadcastConsumer.java

示例2: receiveTransactionMessage

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
/**
 * 接收消息
 */
public void receiveTransactionMessage() {
    DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(RocketMQConfiguration.ROCKETMQ_GROUP);
    consumer.setNamesrvAddr(RocketMQConfiguration.ROCKETMQ_NAMESRV);
    consumer.setVipChannelEnabled(false);
    consumer.setConsumeThreadMax(20);
    consumer.setConsumeThreadMin(10);
    try {
        consumer.subscribe(RocketMQConfiguration.ROCKETMQ_TOPIC, "transaction");
        //程序第一次启动从消息队列头取数据
        consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
        consumer.registerMessageListener(
                new MessageListenerConcurrently() {
                    public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> list, ConsumeConcurrentlyContext Context) {
                        Message msg = list.get(0);
                        System.out.println(msg.toString());
                        return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
                    }
                }
        );
        consumer.start();
    } catch (MQClientException e) {
        e.printStackTrace();
    }
}
 
开发者ID:mumudemo,项目名称:mumu-rocketmq,代码行数:28,代码来源:RocketMQTransactionConsumer.java

示例3: receiveMessage

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
/**
 * 接收消息
 */
public void receiveMessage(){
    DefaultMQPushConsumer consumer =new DefaultMQPushConsumer(RocketMQConfiguration.ROCKETMQ_GROUP);
    consumer.setNamesrvAddr(RocketMQConfiguration.ROCKETMQ_NAMESRV);
    consumer.setVipChannelEnabled(false);
    try {
        consumer.subscribe(RocketMQConfiguration.ROCKETMQ_TOPIC, "schedule");
        //程序第一次启动从消息队列头取数据
        consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
        consumer.registerMessageListener(
                new MessageListenerConcurrently() {
                    public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> list,ConsumeConcurrentlyContext Context) {
                        Message msg = list.get(0);
                        System.out.println(msg.toString());
                        return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
                    }
                }
        );
        consumer.start();
    } catch (MQClientException e) {
        e.printStackTrace();
    }
}
 
开发者ID:mumudemo,项目名称:mumu-rocketmq,代码行数:26,代码来源:RocketMQScheduleConsumer.java

示例4: receiveMessage

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
/**
 * 接收消息
 */
public void receiveMessage(){
    DefaultMQPushConsumer consumer =new DefaultMQPushConsumer(RocketMQConfiguration.ROCKETMQ_GROUP);
    consumer.setNamesrvAddr(RocketMQConfiguration.ROCKETMQ_NAMESRV);
    consumer.setVipChannelEnabled(false);
    try {
        consumer.subscribe(RocketMQConfiguration.ROCKETMQ_TOPIC, "bactch");
        //程序第一次启动从消息队列头取数据
        consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
        consumer.registerMessageListener(
                new MessageListenerConcurrently() {
                    public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> list,ConsumeConcurrentlyContext Context) {
                        Message msg = list.get(0);
                        System.out.println(msg.toString());
                        return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
                    }
                }
        );
        consumer.start();
    } catch (MQClientException e) {
        e.printStackTrace();
    }
}
 
开发者ID:mumudemo,项目名称:mumu-rocketmq,代码行数:26,代码来源:RocketMQBatchConsumer.java

示例5: receiveFilterMessage

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
/**
 * 接收消息
 */
public void receiveFilterMessage(){
    DefaultMQPushConsumer consumer =new DefaultMQPushConsumer(RocketMQConfiguration.ROCKETMQ_GROUP);
    consumer.setNamesrvAddr(RocketMQConfiguration.ROCKETMQ_NAMESRV);
    consumer.setVipChannelEnabled(false);
    try {
        consumer.subscribe(RocketMQConfiguration.ROCKETMQ_TOPIC, MessageSelector.bySql("a between 5 and 8"));
        //程序第一次启动从消息队列头取数据
        consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
        consumer.registerMessageListener(
                new MessageListenerConcurrently() {
                    public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> list, ConsumeConcurrentlyContext Context) {
                        Message msg = list.get(0);
                        System.out.println(msg.toString());
                        return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
                    }
                }
        );
        consumer.start();
    } catch (MQClientException e) {
        e.printStackTrace();
    }
}
 
开发者ID:mumudemo,项目名称:mumu-rocketmq,代码行数:26,代码来源:RocketMQFilterConsumer.java

示例6: receiveMessage

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
/**
 * 接收消息
 */
public void receiveMessage() {
    //获取消费者
    DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(RocketMQConfiguration.ROCKETMQ_GROUP);
    //设置namesrv地址【可以通过环境变量、运行参数来设置】
    consumer.setNamesrvAddr(RocketMQConfiguration.ROCKETMQ_NAMESRV);
    consumer.setVipChannelEnabled(false);
    //设置消费者最大最小线程
    consumer.setConsumeThreadMax(20);
    consumer.setConsumeThreadMin(10);
    try {
        //订阅主题下的所有tag
        consumer.subscribe(RocketMQConfiguration.ROCKETMQ_TOPIC, "*");
        //程序第一次启动从消息队列头取数据
        consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
        //随机获取队列中的消息,相应的是MessageListenerOrderly 按照消息发送顺序来接受消息
        consumer.registerMessageListener(
                new MessageListenerConcurrently() {
                    public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> list, ConsumeConcurrentlyContext Context) {
                        Message msg = list.get(0);
                        System.out.println(msg.toString());
                        return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
                    }
                }
        );
        //启动消费端 线程会一直挂起 等待消息的到来
        consumer.start();
    } catch (MQClientException e) {
        e.printStackTrace();
    }
}
 
开发者ID:mumudemo,项目名称:mumu-rocketmq,代码行数:34,代码来源:RocketMQConsumer.java

示例7: receiveOrderMessage

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
public void receiveOrderMessage(){
    DefaultMQPushConsumer consumer=new DefaultMQPushConsumer(RocketMQConfiguration.ROCKETMQ_GROUP);
    consumer.setNamesrvAddr(RocketMQConfiguration.ROCKETMQ_NAMESRV);
    consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
    try {
        consumer.subscribe(RocketMQConfiguration.ROCKETMQ_TOPIC,"*");
        //监听消息接受
        consumer.registerMessageListener(new MessageListenerOrderly() {
            AtomicLong consumeTimes = new AtomicLong(0);
            @Override
            public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext consumeOrderlyContext) {
                consumeOrderlyContext.setAutoCommit(false);
                System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + new String(msgs.get(0).getBody()) + "%n");
                System.out.println(consumeTimes.incrementAndGet());
                if ((this.consumeTimes.get() % 2) == 0) {
                    return ConsumeOrderlyStatus.SUCCESS;
                } else if ((this.consumeTimes.get() % 3) == 0) {
                    return ConsumeOrderlyStatus.ROLLBACK;
                } else if ((this.consumeTimes.get() % 4) == 0) {
                    return ConsumeOrderlyStatus.COMMIT;
                } else if ((this.consumeTimes.get() % 5) == 0) {
                    consumeOrderlyContext.setSuspendCurrentQueueTimeMillis(3000);
                    return ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT;
                }
                return ConsumeOrderlyStatus.SUCCESS;
            }
        });
        consumer.start();
    } catch (MQClientException e) {
        e.printStackTrace();
    }
}
 
开发者ID:mumudemo,项目名称:mumu-rocketmq,代码行数:33,代码来源:RocketMQOrderConsumer.java

示例8: start

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
public void start() {
    try {
        consumer.start();
        logger.info(String.format("consumer[%s] started!", consumer.getConsumerGroup()));
    } catch (MQClientException e) {
        logger.error("consumer start failed!");
        e.printStackTrace();
    }
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:10,代码来源:RMQNormalConsumer.java

示例9: getRMQProducer

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
public static DefaultMQProducer getRMQProducer(String ns) {
    DefaultMQProducer producer = new DefaultMQProducer(RandomUtil.getStringByUUID());
    producer.setNamesrvAddr(ns);
    try {
        producer.start();
    } catch (MQClientException e) {
        e.printStackTrace();
    }

    return producer;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:12,代码来源:ProducerFactory.java

示例10: start

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
public void start() {
    try {
        producer.start();
        super.setStartSuccess(true);
    } catch (MQClientException e) {
        super.setStartSuccess(false);
        logger.error("producer start failed!");
        e.printStackTrace();
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:11,代码来源:RMQNormalProducer.java

示例11: getMessageQueue

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
@Override
public List<MessageQueue> getMessageQueue() {
    List<MessageQueue> mqs = null;
    try {
        mqs = producer.fetchPublishMessageQueues(topic);
    } catch (MQClientException e) {
        e.printStackTrace();
    }
    return mqs;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:11,代码来源:RMQNormalProducer.java

示例12: start

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
private void start() {
    try {
        producer.start();
    } catch (MQClientException e) {
        logger.error("producer start failed!");
        e.printStackTrace();
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:9,代码来源:RMQAsyncSendProducer.java

示例13: create

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
public void create() {
    consumer = new DefaultMQPushConsumer(consumerGroup);
    consumer.setInstanceName(RandomUtil.getStringByUUID());
    consumer.setNamesrvAddr(nsAddr);
    try {
        consumer.subscribe(topic, subExpression);
    } catch (MQClientException e) {
        logger.error("consumer subscribe failed!");
        e.printStackTrace();
    }
    consumer.setMessageListener(listner);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:13,代码来源:RMQNormalConsumer.java

示例14: subscribe

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
public void subscribe(String topic, String subExpression) {
    try {
        consumer.subscribe(topic, subExpression);
    } catch (MQClientException e) {
        logger.error("consumer subscribe failed!");
        e.printStackTrace();
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:9,代码来源:RMQNormalConsumer.java

示例15: ClusterTestRequestProcessor

import org.apache.rocketmq.client.exception.MQClientException; //导入方法依赖的package包/类
public ClusterTestRequestProcessor(NamesrvController namesrvController, String productEnvName) {
    super(namesrvController);
    this.productEnvName = productEnvName;
    adminExt = new DefaultMQAdminExt();
    adminExt.setInstanceName("CLUSTER_TEST_NS_INS_" + productEnvName);
    adminExt.setUnitName(productEnvName);
    try {
        adminExt.start();
    } catch (MQClientException e) {
        e.printStackTrace();
    }
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:13,代码来源:ClusterTestRequestProcessor.java


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