codelipenghui commented on a change in pull request #5491: Fix message 
deduplicate issue while using external sequence id with batch produce
URL: https://github.com/apache/pulsar/pull/5491#discussion_r342429853
 
 

 ##########
 File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
 ##########
 @@ -382,15 +386,27 @@ public void sendAsync(Message<T> message, SendCallback 
callback) {
                     msgMetadataBuilder.setUncompressedSize(uncompressedSize);
                 }
                 if (canAddToBatch(msg)) {
-                    // handle boundary cases where message being added would 
exceed
-                    // batch size and/or max message size
                     if (canAddToCurrentBatch(msg)) {
-                        batchMessageContainer.add(msg, callback);
-                        lastSendFuture = callback.getFuture();
-                        payload.release();
-                        if (batchMessageContainer.getNumMessagesInBatch() == 
maxNumMessagesInBatch
-                                || batchMessageContainer.getCurrentBatchSize() 
>= BatchMessageContainerImpl.MAX_MESSAGE_BATCH_SIZE_BYTES) {
-                            batchMessageAndSend();
+                        // should trigger complete the batch message, new 
message will add to a new batch and new batch
+                        // sequence id use the new message, so that broker can 
handle the message duplication
+                        if (sequenceId <= lastSequenceIdPushed) {
+                            if (sequenceId <= lastSequenceIdPublished) {
+                                log.warn("Message with sequence id {} is 
definitely a duplicate", sequenceId);
+                            } else {
+                                log.warn("Message with sequence id {} is a 
definitely a duplicate or not cannot be " +
 
 Review comment:
   Ok

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to