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 2019/08/05 12:45:54 UTC

[GitHub] [pulsar-client-go] wolfstudy opened a new pull request #42: [issue:40]Fix producer send protocol error

wolfstudy opened a new pull request #42: [issue:40]Fix producer send protocol error
URL: https://github.com/apache/pulsar-client-go/pull/42
 
 
   Signed-off-by: xiaolong.ran <ra...@gmail.com>
   
   Fixes #40 #39 #33 
   
   ### Motivation
   
   "Payload" command frame format (It has the same 3 fields as a "simple" command, plus the following):
   
   |"Simple" fields var length|magicNumber (0x0e01) 2 bytes|checksum (CRC32-C) 4 bytes| metadataSize (uint32) 4 bytes| metadata (protobuf encoded) var length| payload (bytes) totalSize - (SUM others)|
   |----|----|----|----|----|----|
   ||OPTIONAL If present, indicates following 4 bytes are checksum|OPTIONAL Checksum of the following bytes| size of the metadata| |Any sequence of bytes, possibly compressed and or encrypted (see metadata)|
   
   When using batch messages, the payload will be containing a list of entries, each of them with its individual metadata, defined by the `SingleMessageMetadata` object.
   
   ```
   singleMetaSize(4  bytes) + singleMeta(var length) + payload
   ```
   
   Go client producer send code as follows:
   
   ```
   producer.Send(ctx, &pulsar.ProducerMessage{
               Payload: []byte(fmt.Sprintf("hello-%d", i)),
               Key:     "pulsar",
               Properties: map[string]string{
                   "key":"apache",
               },
   ```
   
   output byte slice as follows:
   
   ```
   0a 0d 0a 03
        6b 65 79 message properties:key(3 bytes)
   12 06
       61 70 61 63 68 65 properties: apache(6 bytes)
   12 06
       70 75 6c 73 61 72 message key: pulsar(6 bytes)
   18 07
       68 65 6c 6c 6f 2d 39 message payload: hello-%d(7 bytes)
   ```
   
   We can see that in the output byte slice, we did not find the singleMetaSize(4 bytes) field in `SingleMessageMetadata`.
   
   
   

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