未验证 提交 29cbfcc0 编写于 作者: H Heng Du 提交者: GitHub

Merge pull request #1548 from qingmg/develop

[ISSUES #1537] Polish docs/cn/RocketMQ_Example.md producer example
...@@ -66,7 +66,11 @@ public class AsyncProducer { ...@@ -66,7 +66,11 @@ public class AsyncProducer {
// 启动Producer实例 // 启动Producer实例
producer.start(); producer.start();
producer.setRetryTimesWhenSendAsyncFailed(0); producer.setRetryTimesWhenSendAsyncFailed(0);
for (int i = 0; i < 100; i++) {
int messageCount = 100;
// 根据消息数量实例化倒计时计算器
final CountDownLatch2 countDownLatch = new CountDownLatch2(messageCount);
for (int i = 0; i < messageCount; i++) {
final int index = i; final int index = i;
// 创建消息,并指定Topic,Tag和消息体 // 创建消息,并指定Topic,Tag和消息体
Message msg = new Message("TopicTest", Message msg = new Message("TopicTest",
...@@ -87,6 +91,8 @@ public class AsyncProducer { ...@@ -87,6 +91,8 @@ public class AsyncProducer {
} }
}); });
} }
// 等待5s
countDownLatch.await(5, TimeUnit.SECONDS);
// 如果不再发送消息,关闭Producer实例。 // 如果不再发送消息,关闭Producer实例。
producer.shutdown(); producer.shutdown();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册