heesung-sn commented on code in PR #21091:
URL: https://github.com/apache/pulsar/pull/21091#discussion_r1311933192


##########
pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawBatchMessageContainerImpl.java:
##########
@@ -90,6 +91,26 @@ public void setCryptoKeyReader(CryptoKeyReader 
cryptoKeyReader) {
         this.cryptoKeyReader = cryptoKeyReader;
     }
 
+    @Override
+    public boolean add(MessageImpl<?> msg, SendCallback callback) {
+        this.lastAddedMessageId = (MessageIdImpl) msg.getMessageId();
+        return super.add(msg, callback);
+    }
+
+    @Override
+    public boolean haveEnoughSpace(MessageImpl<?> msg) {
+        if (lastAddedMessageId == null) {
+            return super.haveEnoughSpace(msg);
+        }
+        // Keep same batch compact to same batch.
+        MessageIdImpl msgId = (MessageIdImpl) msg.getMessageId();
+        if (msgId.getLedgerId() != lastAddedMessageId.getLedgerId()
+                || msgId.getEntryId() != lastAddedMessageId.getEntryId()) {
+            return false;
+        }
+        return super.haveEnoughSpace(msg);

Review Comment:
   Now, I think we should return true here and remove the below member vars. 
This batching should not be bounded by a specific size now.
   
   ```
   this.maxNumMessagesInBatch = maxNumMessagesInBatch;
   this.maxBytesInBatch = maxBytesInBatch;
   ```



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