zongtanghu commented on a change in pull request #2315:
URL: https://github.com/apache/rocketmq/pull/2315#discussion_r491869494
##########
File path:
client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java
##########
@@ -232,6 +232,49 @@ public MessageQueue select(List<MessageQueue> mqs, Message
msg, Object arg) {
countDownLatch.await(3000L, TimeUnit.MILLISECONDS);
assertThat(cc.get()).isEqualTo(5);
}
+
+ @Test
+ public void testBatchSendMessageAsync()
+ throws RemotingException, MQClientException, InterruptedException,
MQBrokerException {
+ final AtomicInteger cc = new AtomicInteger(0);
+ final CountDownLatch countDownLatch = new CountDownLatch(4);
+
+ when(mQClientAPIImpl.getTopicRouteInfoFromNameServer(anyString(),
anyLong())).thenReturn(createTopicRoute());
+ SendCallback sendCallback = new SendCallback() {
+ @Override
+ public void onSuccess(SendResult sendResult) {
+ countDownLatch.countDown();
+ }
+
+ @Override
+ public void onException(Throwable e) {
+ e.printStackTrace();
+ cc.incrementAndGet();
+ countDownLatch.countDown();
+ }
+ };
+ MessageQueueSelector messageQueueSelector = new MessageQueueSelector()
{
+ @Override
+ public MessageQueue select(List<MessageQueue> mqs, Message msg,
Object arg) {
+ return null;
+ }
+ };
+
+ List<Message> msgs = new ArrayList<>();
+ for (int i = 0; i < 5; i++) {
+ Message message = new Message();
+ message.setTopic("test");
+ message.setBody(("hello world" + i).getBytes());
+ msgs.add(message);
+ }
+ producer.send(msgs, sendCallback);
+ producer.send(msgs, sendCallback, 1000);
+ producer.send(msgs, new MessageQueue(), sendCallback);
+ producer.send(msgs, new MessageQueue(), sendCallback, 1000);
Review comment:
I have a question, here you can add another test case to coverage the
case which send message successfully based on the specified message queue.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]