odbozhou commented on a change in pull request #1240: [ISSUE #1199] Implement 
the 1.0.0 openmessaging new consumer API for rocketmq oms module
URL: https://github.com/apache/rocketmq/pull/1240#discussion_r294090234
 
 

 ##########
 File path: 
openmessaging/src/test/java/io/openmessaging/rocketmq/consumer/PushConsumerImplTest.java
 ##########
 @@ -88,4 +91,58 @@ public void onReceived(Message message, Context context) {
         ((MessageListenerConcurrently) rocketmqPushConsumer
                 
.getMessageListener()).consumeMessage(Collections.singletonList(consumedMsg), 
null);
     }
+
+    @Test
+    public void testBatchConsumeMessage() {
+        final byte[] testBody = new byte[]{'a', 'b'};
+
+        MessageExt consumedMsg = new MessageExt();
+        consumedMsg.setMsgId("NewMsgId");
+        consumedMsg.setBody(testBody);
+        consumedMsg.putUserProperty(NonStandardKeys.MESSAGE_DESTINATION, 
"TOPIC");
+        consumedMsg.setTopic("HELLO_QUEUE");
+        consumedMsg.setQueueId(0);
+        consumedMsg.setStoreHost(new InetSocketAddress("127.0.0.1", 9876));
+
+        final byte[] testBody1 = new byte[]{'c', 'd'};
+        MessageExt consumedMsg1 = new MessageExt();
+        consumedMsg1.setMsgId("NewMsgId1");
+        consumedMsg1.setBody(testBody1);
+        consumedMsg1.putUserProperty(NonStandardKeys.MESSAGE_DESTINATION, 
"TOPIC");
+        consumedMsg1.setTopic("HELLO_QUEUE");
+        consumedMsg1.setQueueId(0);
+        consumedMsg1.setStoreHost(new InetSocketAddress("127.0.0.1", 9876));
+        List<MessageExt> messageExts = new ArrayList<MessageExt>() {
+            {
+                add(consumedMsg);
+                add(consumedMsg1);
+            }
+        };
+
+        Set<String> queueNames = new HashSet<>(8);
+        queueNames.add("HELLO_QUEUE");
+        pushConsumer.bindQueue(queueNames, new BatchMessageListener() {
+            @Override public void onReceived(List<Message> batchMessage, 
Context context) {
+                assertThat(batchMessage.size()).isEqualTo(2);
+                Message message1 = null;
+                Message message2 = null;
+                for (Message message : batchMessage) {
+                    if (message.header().getMessageId().equals("NewMsgId")) {
+                        message1 = message;
+                    }
+                    if (message.header().getMessageId().equals("NewMsgId1")) {
+                        message2 = message;
+                    }
+                }
+                assertThat(message1).isNotNull();
 
 Review comment:
   This has increased verification

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to