赞
踩
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)
用注解的形式配置时不用手动启动 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; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。