liangyepianzhou commented on code in PR #20948:
URL: https://github.com/apache/pulsar/pull/20948#discussion_r1290863023


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java:
##########
@@ -594,13 +595,18 @@ private void updateMessageMetadata(final MessageMetadata 
msgMetadata, final int
         }
     }
 
-    private long updateMessageMetadataSequenceId(final MessageMetadata 
msgMetadata) {
+    private long updateMessageMetadataSequenceId(final MessageMetadata 
msgMetadata, boolean isChunk) {
         final long sequenceId;
+        // We always need to increment the value of `msgIdGenerator`,
+        // regardless of whether the user has set a sequence ID when sending a 
message.
         if (!msgMetadata.hasSequenceId()) {
             sequenceId = msgIdGenerator++;
             msgMetadata.setSequenceId(sequenceId);
+        } else if (isChunk) {
+            sequenceId = msgIdGenerator++;

Review Comment:
   For case 1, If users send a message setting seq_id <= the seq_id of the 
previous message, the message will be dropped by duplication. But I think it 
should return an exception when users set seq_id < msgIdGenerator. It is 
another problem and maybe a breaking-changes, soI will fix it in another PR.
   
   For case 2, It's true. It seems that we don't have a way to fix this issue 
on the client side without introducing a breaking change. Therefore, I made 
some optimizations on the broker side. For bug fixes, it's still preferable to 
avoid introducing breaking changes, as we would need to cherry-pick them into 
older branches.



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