codelipenghui commented on code in PR #17318:
URL: https://github.com/apache/pulsar/pull/17318#discussion_r990716151


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java:
##########
@@ -839,7 +839,7 @@ protected boolean canEnqueueMessage(Message<T> message) {
 
     protected boolean enqueueMessageAndCheckBatchReceive(Message<T> message) {
         int messageSize = message.size();
-        if (canEnqueueMessage(message) && incomingMessages.offer(message)) {
+        if (isValidConsumerEpoch(message) && canEnqueueMessage(message) && 
incomingMessages.offer(message)) {

Review Comment:
   > For users, when having pending receive, It does not call the 
redeliverUnacknowledgedMessages method. The following usage is recommended.
   
   @shibd I see. Thanks for the explanation.
   
   It looks like we should not have pending receive requests during the message 
redelivery. From the understandability and sustainability, we should make it 
clear that all the messages with an unexpected epoch number will be filtered 
out. Now, it looks like we must know call 
`consumer.redeliverUnacknowledgedMessages()` doesn't make any sense before the 
`receive()` method. If we just read the code, I think a lot of people would 
think this might be a place to be missed, it is not easy to understand how 
correctness is guaranteed.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to