You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "pzx6b666 (via GitHub)" <gi...@apache.org> on 2024/05/28 07:09:27 UTC
[I] Producer is not running now 消息发送以后再发送消息就报这个错,把producer.close(); 去了就不报错 [rocketmq-clients]
pzx6b666 opened a new issue, #764:
URL: https://github.com/apache/rocketmq-clients/issues/764
### Programming Language of the Client
Java
### Is Your Feature Request Related to a Problem?
final ClientServiceProvider provider = ClientServiceProvider.loadService();
String topic = "yourNormalTopic";
final Producer producer = ProducerSingleton.getInstance(topic);
byte[] body = "This is a normal message for Apache RocketMQ".getBytes(StandardCharsets.UTF_8);
String tag = "yourMessageTagA";
final Message message = provider.newMessageBuilder()
.setTopic(topic)
.setTag(tag)
.setKeys("yourMessageKey-1c151062f96e")
.setBody(body)
.build();
try {
final SendReceipt sendReceipt = producer.send(message);
log.info("Send message successfully, messageId={}", sendReceipt.getMessageId());
} catch (Throwable t) {
log.error("Failed to send message", t);
}
producer.close();
### Describe the Solution You'd Like
1
### Describe Alternatives You've Considered
1
### Additional Context
1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Producer is not running now 消息发送以后再发送消息就报这个错,把producer.close(); 去了就不报错 [rocketmq-clients]
Posted by "pzx6b666 (via GitHub)" <gi...@apache.org>.
pzx6b666 commented on issue #764:
URL: https://github.com/apache/rocketmq-clients/issues/764#issuecomment-2134525742
> 本来就是这样的,你都关闭生产者了,他肯定报错呀
第一次调用发送完消息以后执行close,再次调用不应该重新初始化吗
sendmsg(){
final ClientServiceProvider provider = ClientServiceProvider.loadService();
String topic = "yourNormalTopic";
final Producer producer = ProducerSingleton.getInstance(topic);
byte[] body = "This is a normal message for Apache RocketMQ".getBytes(StandardCharsets.UTF_8);
String tag = "yourMessageTagA";
final Message message = provider.newMessageBuilder()
.setTopic(topic)
.setTag(tag)
.setKeys("yourMessageKey-1c151062f96e")
.setBody(body)
.build();
try {
final SendReceipt sendReceipt = producer.send(message);
log.info("Send message successfully, messageId={}", sendReceipt.getMessageId());
} catch (Throwable t) {
log.error("Failed to send message", t);
}finally{
producer.close()
}
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Producer is not running now 消息发送以后再发送消息就报这个错,把producer.close(); 去了就不报错 [rocketmq-clients]
Posted by "JanYork (via GitHub)" <gi...@apache.org>.
JanYork commented on issue #764:
URL: https://github.com/apache/rocketmq-clients/issues/764#issuecomment-2134510117
本来就是这样的,你都关闭生产者了,他肯定报错呀
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org