BewareMyPower commented on a change in pull request #12403:
URL: https://github.com/apache/pulsar/pull/12403#discussion_r775121476



##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
##########
@@ -1178,12 +1190,46 @@ protected boolean 
verifyLocalBufferIsNotCorrupted(OpSendMsg op) {
         }
     }
 
+    static class ChunkedMessageCtx {

Review comment:
       It's not necessary to introduce this class as a field of `OpSendMsg` 
because `OpSendMsg` is already managed by Netty recycler. It's too complex to 
introduce a field that is also managed by Netty recycler.
   
   I'd prefer adding two fields to `OpSendMsg`:
   
   ```java
           MessageIdImpl firstChunkMessageId;
           MessageIdImpl lastChunkMessageId;
   ```
   
   Then in `ackReceived` you can just write
   
   ```java
           if (op.totalChunks > 1) {
               if (op.chunkId == 0) {
                   op.firstChunkMessageId = new MessageIdImpl(ledgerId, 
entryId, partitionIndex);
               } else if (op.chunkId == op.totalChunks - 1) {
                   op.lastChunkMessageId = new MessageIdImpl(ledgerId, entryId, 
partitionIndex);
                   op.setMessageId(new 
ChunkMessageIdImpl(op.firstChunkMessageId, op.lastChunkMessageId));
               }
           }
   ```
   
   After that, the code will be more clear.




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