zhouxinyu commented on a change in pull request #219: [ROCKETMQ-355] Client 
asyncSend is not fully async
URL: https://github.com/apache/rocketmq/pull/219#discussion_r161971194
 
 

 ##########
 File path: 
client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java
 ##########
 @@ -214,6 +218,54 @@ public void testSetCallbackExecutor() throws 
MQClientException {
         assertThat(remotingClient.getCallbackExecutor()).isEqualTo(customized);
     }
 
+    @Test
+    public void testAsyncSend() throws MQClientException, RemotingException, 
InterruptedException {
+        String producerGroupTemp = producerGroupPrefix + 
System.currentTimeMillis();
+        producer = new DefaultMQProducer(producerGroupTemp);
+        producer.setNamesrvAddr("127.0.0.1:9876");
+        producer.start();
+
+        final AtomicInteger cc = new AtomicInteger(0);
+        final CountDownLatch countDownLatch = new CountDownLatch(6);
+
+        SendCallback sendCallback = new SendCallback() {
+            @Override
+            public void onSuccess(SendResult sendResult) {
+
+            }
+
+            @Override
+            public void onException(Throwable e) {
+                e.printStackTrace();
+                countDownLatch.countDown();
+                cc.incrementAndGet();
+            }
+        };
+        MessageQueueSelector messageQueueSelector = new MessageQueueSelector() 
{
+            @Override
+            public MessageQueue select(List<MessageQueue> mqs, Message msg, 
Object arg) {
+                return null;
+            }
+        };
+
+        Message message = new Message();
+        message.setTopic("test");
+        message.setBody("hello world".getBytes());
+        producer.send(new Message(),sendCallback);
+        producer.send(message,sendCallback,1000);
+        producer.send(message,new MessageQueue(),sendCallback);
+        producer.send(new Message(),new MessageQueue(),sendCallback,1000);
+        producer.send(new Message(),messageQueueSelector,null,sendCallback);
+        producer.send(message,messageQueueSelector,null,sendCallback,1000);
+
+        countDownLatch.await(1000L, TimeUnit.MILLISECONDS);
+
+        assertThat(cc.get()).isEqualTo(6);
+//        producer.sendOneway(new Message());
+//        producer.sendOneway(new Message(),new MessageQueue());
+//        producer.sendOneway(new Message(),messageQueueSelector,null);
 
 Review comment:
   Please remove these unused code lines?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to