lhotari commented on code in PR #25555:
URL: https://github.com/apache/pulsar/pull/25555#discussion_r3117285678


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Producer.java:
##########
@@ -223,14 +229,19 @@ public void publishMessage(long producerId, long 
lowestSequenceId, long highestS
             });
             return;
         }
-        if (checkAndStartPublish(producerId, highestSequenceId, 
headersAndPayload, batchSize, position)) {
-            publishMessageToTopic(headersAndPayload, lowestSequenceId, 
highestSequenceId, batchSize, isChunked,
-                    isMarker, position);
+        MessagePublishContext messagePublishContext = 
MessagePublishContext.get(this, lowestSequenceId,
+                highestSequenceId, headersAndPayload.readableBytes(), 
batchSize,
+                isChunked, System.nanoTime(), isMarker, position, 
isSupportsReplDedupByLidAndEid());
+        if (checkAndStartPublish(producerId, highestSequenceId, 
headersAndPayload, batchSize, position,
+                messagePublishContext)) {
+            publishMessageToTopic(headersAndPayload, messagePublishContext);
+        } else {
+            messagePublishContext.recycle();
         }
     }
 
     public boolean checkAndStartPublish(long producerId, long sequenceId, 
ByteBuf headersAndPayload, int batchSize,
-                                        Position position) {
+                                        Position position, PublishContext 
publishContext) {

Review Comment:
   Adding headersAndPayload to the PublishContext would break a lot of things 
so keeping that out of PublishContext makes sense. Just omitting the parameters 
that are already in PublishContext would be useful here.



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