rocketmq发送消息代码

        DefaultMQProducer defaultMQProducer = new DefaultMQProducer();
        defaultMQProducer.setProducerGroup(Constant.operationLogGroup);
        defaultMQProducer.setInstanceName(Constant.operationLogInstance);
        defaultMQProducer.setNamesrvAddr(Constant.rocketQueneAddr);
        try {
            defaultMQProducer.start();
            defaultMQProducer.send(message);
        } catch (Exception e) {
            logger.error("produce operation log message error", e);
        } finally {
            defaultMQProducer.shutdown();
        }
posted @ 2017-08-01 08:52  jhcelue  阅读(300)  评论(0编辑  收藏  举报