当前位置:   article > 正文

RocketMq报错MQClientExceptionThe producer service state not OK, maybe started once, RUNNING_org.apache.rocketmq.client.exception.mqclientexcep

org.apache.rocketmq.client.exception.mqclientexception: the producer service

项目启动报错:

org.apache.rocketmq.client.exception.MQClientException: The producer service state not OK, maybe started once, RUNNING
See http://rocketmq.apache.org/docs/faq/ for further details.
 
	at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.start(DefaultMQProducerImpl.java:185)
	at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.start(DefaultMQProducerImpl.java:146)
  • 1
  • 2
  • 3
  • 4
  • 5

问题原因:

用注解的形式配置时不用手动启动 producer,所以把producer.start() 的代码删除就OK了。

我是用的@Bean配置DefaultMQProducer,把下面producer.start();注释掉就了。

@Bean
    public DefaultMQProducer getRocketMQProducer() throws MQClientException {
        DefaultMQProducer producer;
        producer = new DefaultMQProducer(properties.getGroupName());
        producer.setNamesrvAddr(properties.getNameServer());
        producer.setMaxMessageSize(properties.getProducerMaxMessageSize());
        producer.setSendMsgTimeout(properties.getProducerSendMsgTimeout());
        producer.setRetryTimesWhenSendFailed(properties.getProducerRetryTimesWhenSendFailed());
//
//        try {
//            producer.start();
//            log.info("producer is start ! groupName:{},namesrvAddr:{}", properties.getGroupName(), properties.getNameServer());
//        } catch (MQClientException e) {
//            log.error("producer is error {}", e.getMessage(), e);
//            throw e;
//        }
        return producer;

    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/256987
推荐阅读
相关标签
  

闽ICP备14008679号