You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/05/21 22:32:24 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #4331: Bugfix - don't discard first entry after reset

merlimat commented on a change in pull request #4331: Bugfix - don't discard first entry after reset
URL: https://github.com/apache/pulsar/pull/4331#discussion_r286250314
 
 

 ##########
 File path: pulsar-broker/src/test/java/org/apache/pulsar/client/api/TopicReaderTest.java
 ##########
 @@ -650,4 +647,44 @@ public void testReaderIsAbleToSeekWithTimeOnMiddleOfTopic() throws Exception {
         reader.close();
         producer.close();
     }
+
+    @Test
+    public void testReaderStartMessageIdAtExpectedPosition() throws Exception {
+        final int numOfMessage = 10;
+        final String topicName = "persistent://my-property/my-ns/ReaderStartMessageIdAtExpectedPosition";
+        final int resetIndex = new Random().nextInt(numOfMessage); // Choose some random index to reset
+
+        Producer<byte[]> producer = pulsarClient.newProducer()
+                .topic(topicName).create();
+
+        MessageId resetPos = null;
+        for (int i = 0; i < numOfMessage; i++) {
+
+            MessageId msgId = producer.send(String.format("msg num %d", i).getBytes());
+            if (resetIndex == i) {
+                resetPos = msgId;
+            }
+        }
+
+        Reader<byte[]> reader = pulsarClient.newReader()
+                .topic(topicName)
+                .startMessageId(resetPos)
 
 Review comment:
   The javadoc says that the message will be the one *after* the resetPos. Typically, the "resetPos" is the messageId you checkpoint after processing. 
   
   Indeed there might be cases in which one desires to start reading from that message included. This should be achieved through some other config option.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services