gaoran10 commented on a change in pull request #12720:
URL: https://github.com/apache/pulsar/pull/12720#discussion_r750000070



##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
##########
@@ -479,6 +479,13 @@ public void sendAsync(Message<?> message, SendCallback 
callback) {
                 }
                 String uuid = totalChunks > 1 ? String.format("%s-%d", 
producerName, sequenceId) : null;
                 for (int chunkId = 0; chunkId < totalChunks; chunkId++) {
+                    // Need to reset the schemaVersion, because the 
schemaVersion is a ByteBuf object in
+                    // `MessageMetadata`, if we want to re-serialize the 
`SEND` command using a same `MessageMetadata`,
+                    // we need to reset the ByteBuf of the schemaVersion in 
`MessageMetadata`, I think we need to
+                    // reset `ByteBuf` objects in `MessageMetadata` after call 
the method `MessageMetadata#writeTo()`.
+                    if (chunkId > 0 && 
msg.getMessageBuilder().hasSchemaVersion()) {

Review comment:
       The `MessageMetadata` is used to serialize protobuf data, if we want to 
call the method `writeTo()` of the class `MessageMetadata` multi times, it's 
better to modify the logic of the `MessageMetadata`, the read index of 
`ByteBuf` object should be reset after writing.
   
   

##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
##########
@@ -479,6 +479,13 @@ public void sendAsync(Message<?> message, SendCallback 
callback) {
                 }
                 String uuid = totalChunks > 1 ? String.format("%s-%d", 
producerName, sequenceId) : null;
                 for (int chunkId = 0; chunkId < totalChunks; chunkId++) {
+                    // Need to reset the schemaVersion, because the 
schemaVersion is a ByteBuf object in
+                    // `MessageMetadata`, if we want to re-serialize the 
`SEND` command using a same `MessageMetadata`,
+                    // we need to reset the ByteBuf of the schemaVersion in 
`MessageMetadata`, I think we need to
+                    // reset `ByteBuf` objects in `MessageMetadata` after call 
the method `MessageMetadata#writeTo()`.
+                    if (chunkId > 0 && 
msg.getMessageBuilder().hasSchemaVersion()) {

Review comment:
       The `MessageMetadata` is used to serialize protobuf data, if we want to 
call the method `writeTo()` of the class `MessageMetadata` multi times, maybe 
it's better to modify the logic of the `MessageMetadata`, the read index of 
`ByteBuf` object should be reset after writing.
   
   




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