BewareMyPower commented on code in PR #19031:
URL: https://github.com/apache/pulsar/pull/19031#discussion_r1059642489


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -204,6 +208,10 @@
 
     private final AtomicReference<ClientCnx> 
clientCnxUsedForConsumerRegistration = new AtomicReference<>();
     private final List<Throwable> previousExceptions = new 
CopyOnWriteArrayList<Throwable>();
+    // Key is the ledger id and the entry id, entry is the acker that 
represents which single messages are acknowledged
+    private final ConcurrentNavigableMap<Pair<Long, Long>, BatchMessageAcker> 
batchMessageToAcker =

Review Comment:
   > Users should not continue to process/ack the messages before the seek 
operation.
   
   This implicit rule is never documented and even it's documented, it could be 
a burden to users.
   
   Assuming there are a message ID set, given the following steps:
   1. Acnowledge some message IDs
   2. Perform some operations, e.g. `seek`.
   3. Acknowledge other message IDs.
   
   ```java
   consumer.acknowledge(msgId1);
   consumer.doSomething(); // pseudo code
   consumer.acknowledge(msgId2);
   ```
   
   The rule means, the steps above could have the different result with 
acknowledging the whole message ID set:
   
   ```java
   consumer.acknowledge(msgId1);
   consumer.acknowledge(msgId2);
   ```
   
   A more confusing thing is that with this rule, consumer can acknowledge 
another message ID that has the same position with `msgId1` to have the same 
result. i.e.
   
   ```java
   // CODE 1
   consumer.acknowledge(msgId1);
   consumer.doSomething();
   consumer.acknowledge(msgId2);
   consumer.acknowledge(msgId3);
   // msgId3.getLedgerId() == msgId1.getLedgerId()
   // msgId3.getEntryId() == msgId1.getEntryId()
   // msgId3.getBatchIndex() == msgId1.getBatchIndex()
   ``` 
   
   is equivalent with
   
   ```java
   // CODE 2
   consumer.acknowledge(msgId1);
   consumer.acknowledge(msgId2);
   ```
   
   What's more confusing is, `msgId1.equals(msgId3)` is true and if we replace 
`consumer.acknowledge(msgId3)` with `consumer.acknowledge(msgId1)` in `CODE 1`, 
`CODE 1` won't be equivalent with `CODE 2`.
   



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