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/09/01 02:48:06 UTC

[GitHub] [pulsar] shengjh opened a new issue #7945: How to send a c++ struct using schema in producer ?

shengjh opened a new issue #7945:
URL: https://github.com/apache/pulsar/issues/7945


   Hello, I'm trying to send a c++ struct(protobuf generated from proto file) in my c++ producer. 
   I can set a schema for a producer, but i don't know how to send my struct.(seems the cpp doc does not explain this.)
   
   The question is, what should be passed to MessageBuilder().setContent(...)?
   ```cpp
   Message msg = MessageBuilder().setContent(...).build();
   Result res = producer.send(msg);
   ```


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



[GitHub] [pulsar] BewareMyPower commented on issue #7945: How to send a c++ struct using schema in producer ?

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on issue #7945:
URL: https://github.com/apache/pulsar/issues/7945#issuecomment-684187324


   There're 2 ways to create a `Message` with C++ client
   
   ```c++
       /**
        * Set content of the message. The message contents will be managed by the system.
        */
       MessageBuilder& setContent(const void* data, size_t size);
       MessageBuilder& setContent(const std::string& data);
   
       /**
        * Set content of the message to a buffer already allocated by the caller. No copies of
        * this buffer will be made. The caller is responsible to ensure the memory buffer is
        * valid until the message has been persisted (or an error is returned).
        */
       MessageBuilder& setAllocatedContent(void* data, size_t size);
   ```
   
   - data: the pointer to your struct
   - size: the struct's size


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



[GitHub] [pulsar] BewareMyPower commented on issue #7945: How to send a c++ struct using schema in producer ?

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on issue #7945:
URL: https://github.com/apache/pulsar/issues/7945#issuecomment-684505993


   You should encode your struct manually, see [#5057](https://github.com/apache/pulsar/issues/5057)


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



[GitHub] [pulsar] shengjh commented on issue #7945: How to send a c++ struct using schema in producer ?

Posted by GitBox <gi...@apache.org>.
shengjh commented on issue #7945:
URL: https://github.com/apache/pulsar/issues/7945#issuecomment-684659348


   Thanks, @BewareMyPower 


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



[GitHub] [pulsar] shengjh commented on issue #7945: How to send a c++ struct using schema in producer ?

Posted by GitBox <gi...@apache.org>.
shengjh commented on issue #7945:
URL: https://github.com/apache/pulsar/issues/7945#issuecomment-684449592


   In this way, how to deserialize the message in consumer? My consumer is using go client.


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



[GitHub] [pulsar] shengjh closed issue #7945: How to send a c++ struct using schema in producer ?

Posted by GitBox <gi...@apache.org>.
shengjh closed issue #7945:
URL: https://github.com/apache/pulsar/issues/7945


   


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