You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/04/11 02:58:11 UTC

[GitHub] [pulsar] liudezhi2098 opened a new pull request #6715: fix_admin_getIndividualMsgsFromBatch_bug

liudezhi2098 opened a new pull request #6715: fix_admin_getIndividualMsgsFromBatch_bug
URL: https://github.com/apache/pulsar/pull/6715
 
 
   **Motivation**
   fix when get batch message from http response, only get the first message. #6714
   ```javascript
   for (int i = 0; i < batchSize; i++) {
               String batchMsgId = msgId + ":" + i;
               PulsarApi.SingleMessageMetadata.Builder singleMessageMetadataBuilder = PulsarApi.SingleMessageMetadata
                       .newBuilder();
               ByteBuf buf = Unpooled.wrappedBuffer(data); // here you need to move out of the loop
               try {
                   ByteBuf singleMessagePayload = Commands.deSerializeSingleMessageInBatch(buf, singleMessageMetadataBuilder, i,
                           batchSize);
                   SingleMessageMetadata singleMessageMetadata = singleMessageMetadataBuilder.build();
                   if (singleMessageMetadata.getPropertiesCount() > 0) {
                       for (KeyValue entry : singleMessageMetadata.getPropertiesList()) {
                           properties.put(entry.getKey(), entry.getValue());
                       }
                   }
                   ret.add(new MessageImpl<>(topic, batchMsgId, properties, singleMessagePayload, Schema.BYTES));
               } catch (Exception ex) {
                   log.error("Exception occured while trying to get BatchMsgId: {}", batchMsgId, ex);
               }
               buf.release();
               singleMessageMetadataBuilder.recycle();
           }
   ```
   ByteBuf buf  need to move out of the loop
   
   **Changes**
   Replace old value with new value
   ```javascript
    ByteBuf buf = Unpooled.wrappedBuffer(data);
           for (int i = 0; i < batchSize; i++) {
               String batchMsgId = msgId + ":" + i;
               PulsarApi.SingleMessageMetadata.Builder singleMessageMetadataBuilder = PulsarApi.SingleMessageMetadata
                       .newBuilder();
               try {
                   ByteBuf singleMessagePayload =
                           Commands.deSerializeSingleMessageInBatch(buf, singleMessageMetadataBuilder, i, batchSize);
                   SingleMessageMetadata singleMessageMetadata = singleMessageMetadataBuilder.build();
                   if (singleMessageMetadata.getPropertiesCount() > 0) {
                       for (KeyValue entry : singleMessageMetadata.getPropertiesList()) {
                           properties.put(entry.getKey(), entry.getValue());
                       }
                   }
                   ret.add(new MessageImpl<>(topic, batchMsgId, properties, singleMessagePayload, Schema.BYTES));
               } catch (Exception ex) {
                   log.error("Exception occured while trying to get BatchMsgId: {}", batchMsgId, ex);
               }
               singleMessageMetadataBuilder.recycle();
           }
           buf.release();
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [pulsar] jiazhai commented on issue #6715: fix_admin_getIndividualMsgsFromBatch_bug

Posted by GitBox <gi...@apache.org>.
jiazhai commented on issue #6715: fix_admin_getIndividualMsgsFromBatch_bug
URL: https://github.com/apache/pulsar/pull/6715#issuecomment-612549527
 
 
   /pulsarbot run-failure-checks
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [pulsar] sijie merged pull request #6715: fix_admin_getIndividualMsgsFromBatch_bug

Posted by GitBox <gi...@apache.org>.
sijie merged pull request #6715: fix_admin_getIndividualMsgsFromBatch_bug
URL: https://github.com/apache/pulsar/pull/6715
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services