michaeljmarshall commented on code in PR #19191:
URL: https://github.com/apache/pulsar/pull/19191#discussion_r1068553187


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java:
##########
@@ -873,14 +869,23 @@ private boolean canAddToCurrentBatch(MessageImpl<?> msg) {
                 && batchMessageContainer.hasSameTxn(msg);
     }
 
+    private void triggerSendIfFullOrScheduleFlush(boolean isBatchFull) {
+        if (isBatchFull) {
+            batchMessageAndSend(false);
+        } else {
+            maybeScheduleBatchFlushTask();
+        }
+    }
+
     private void doBatchSendAndAdd(MessageImpl<?> msg, SendCallback callback, 
ByteBuf payload) {
         if (log.isDebugEnabled()) {
             log.debug("[{}] [{}] Closing out batch to accommodate large 
message with size {}", topic, producerName,
                     msg.getUncompressedSize());
         }
         try {
             batchMessageAndSend(false);
-            batchMessageContainer.add(msg, callback);
+            boolean isBatchFull = batchMessageContainer.add(msg, callback);
+            triggerSendIfFullOrScheduleFlush(isBatchFull);
             lastSendFuture = callback.getFuture();

Review Comment:
   Should this be before the call to `triggerSendIfFullOrScheduleFlush`? It is 
in the other usage of `triggerSendIfFullOrScheduleFlush`. However, we're in a 
`synchronized (this)` block, so it might be fine.



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