merlimat commented on a change in pull request #4645: Allows consumer retrieve 
the sequence id that the producer set.
URL: https://github.com/apache/pulsar/pull/4645#discussion_r299260480
 
 

 ##########
 File path: 
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageTest.java
 ##########
 @@ -737,5 +737,69 @@ public void testOrderingOfKeyBasedBatchMessageContainer() 
throws PulsarClientExc
         producer.close();
     }
 
+    @Test(dataProvider = "containerBuilder", timeOut = 3000)
+    private void testRetrieveSequenceIdGenerated(BatcherBuilder builder) 
throws Exception {
+
+        int numMsgs = 10;
+        final String topicName = 
"persistent://prop/ns-abc/testRetrieveSequenceIdGenerated-" + UUID.randomUUID();
+        final String subscriptionName = "sub-1";
+
+        Consumer<byte[]> consumer = 
pulsarClient.newConsumer().topic(topicName).subscriptionName(subscriptionName)
+                .subscriptionType(SubscriptionType.Shared).subscribe();
+
+        Producer<byte[]> producer = pulsarClient.newProducer().topic(topicName)
+                .batchingMaxPublishDelay(5, 
TimeUnit.SECONDS).batchingMaxMessages(numMsgs).enableBatching(true)
+                .batcherBuilder(builder)
+                .create();
+
+        List<CompletableFuture<MessageId>> sendFutureList = 
Lists.newArrayList();
+        for (int i = 0; i < numMsgs; i++) {
+            byte[] message = ("my-message-" + i).getBytes();
+            sendFutureList.add(producer.sendAsync(message));
+        }
+        FutureUtil.waitForAll(sendFutureList).get();
+
+        for (int i = 0; i < numMsgs; i++) {
+            Message<byte[]> received = consumer.receive();
+            Assert.assertEquals(received.getSequenceId(), i);
+            consumer.acknowledge(received);
+        }
+
+        producer.close();
+        consumer.close();
+    }
+
+    @Test(dataProvider = "containerBuilder", timeOut = 3000)
 
 Review comment:
   ```suggestion
       @Test(dataProvider = "containerBuilder")
   ```

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