You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by gi...@git.apache.org on 2017/08/29 19:12:28 UTC

[GitHub] rdhabalia commented on a change in pull request #720: Position Reader on a specific message within a batch

rdhabalia commented on a change in pull request #720: Position Reader on a specific message within a batch
URL: https://github.com/apache/incubator-pulsar/pull/720#discussion_r135885576
 
 

 ##########
 File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
 ##########
 @@ -859,6 +865,21 @@ void receiveIndividualMessagesFromBatch(MessageMetadata msgMetadata, ByteBuf unc
                     .newBuilder();
                 ByteBuf singleMessagePayload = Commands.deSerializeSingleMessageInBatch(uncompressedPayload,
                     singleMessageMetadataBuilder, i, batchSize);
+
+                if (startMessageId != null
+                        && messageId.getLedgerId() == startMessageId.getLedgerId()
+                        && messageId.getEntryId() == startMessageId.getEntryId()
+                        && i <= startMessageId.getBatchIndex()) {
+                    // If we are receiving a batch message, we need to discard messages that were prior
+                    // to the startMessageId
 
 Review comment:
   just a quick suggestion if that make sense.
   1. what if we also add similar validation at `messageReceived()` for non-batch-msg also where we skip the message if `receivedMsgId < startMessageId`
   2. and at [broker ](https://github.com/merlimat/pulsar/blob/fa752f4f990c7cd604bee8fea3cc5aaf33bfe291/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java?utf8=%E2%9C%93#L477-L483) we always read from `entryId=entryId-1` and duplicate entry will be anyway skipped by the client.
   
   In this way, broker can be `BatchMessage` agnostic and it will not have any batch-msg specific logic as it treats  batch-msg as normal msg only.
 
----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services