You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/11/03 04:04:55 UTC

[GitHub] [rocketmq] Git-Yang commented on issue #3453: Producer cannot shutdown completely

Git-Yang commented on issue #3453:
URL: https://github.com/apache/rocketmq/issues/3453#issuecomment-958640669


   > > public class SyncProducer { public static void main(String[] args) throws Throwable { //1、创建消息生产者producer,并指定生产者的组名 DefaultMQProducer producer = new DefaultMQProducer("group1"); //2、指定nameserver地址,可以用分号隔开10.0.0.99:9876;10.0.0.68:9876 producer.setNamesrvAddr("10.0.0.99:9876"); //3、启动producer producer.start(); //4、创建消息对象,指定主题Topic,Tag和消息体 for (int i = 0; i < 1; i++) { /** * 参数一:消息的Topic名称,自定义 * 参数二:消息的Tag名称,自定义 * 参数三:消息的内容 * */ Message msg = new Message("base", "tag1", ("Hello RocketMQ" + i).getBytes(StandardCharsets.UTF_8)); //5、发送消息 SendResult result = producer.send(msg); SendStatus status = result.getSendStatus();//发送状态 String msgId = result.getMsgId();//消息id int queueId = result.getMessageQueue().getQueueId();//队列id System.out.println("发送结果>" + result); TimeUnit.SECONDS.sl
 eep(1);//休眠1秒 } //6、关闭生产者producer producer.shutdown(); System.out.println("ffffff"); } } 当执行到//6、关闭生产者producer producer.shutdown();程序main无法正常退出,线程还在挂起<dependency> <groupId>org.apache.rocketmq</groupId> <artifactId>rocketmq-client</artifactId> <version>4.9.2</version> </dependency> 4.9.2有这样的问题,4.4.0没有这样的问题,其他的版本我没测试
   > 
   > Good catch!We will fix it ASAP.
   
   I just identified this problem. The reason why the thread cannot exit is that the internally built ScheduledExecutorService thread pool cannot exit.
   <img width="1409" alt="1" src="https://user-images.githubusercontent.com/30995057/140008606-2effebba-ef6c-4da4-892b-dd2ee098d84c.png">
   <img width="1413" alt="2" src="https://user-images.githubusercontent.com/30995057/140008615-903fc7a4-be63-447c-9a14-07f32e6dcbcc.png">
   <img width="1424" alt="3" src="https://user-images.githubusercontent.com/30995057/140008618-887a364d-5c91-4388-8829-eef30d32f767.png">
   
   
   


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org