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/21 17:04:20 UTC

[GitHub] [pulsar] bschofield edited a comment on issue #6785: go client: message ID serialization / deserialization does not work with multi-topic consumers

bschofield edited a comment on issue #6785:
URL: https://github.com/apache/pulsar/issues/6785#issuecomment-617285319


   I rescind the last paragraph I thought that `pulsar.MessageID`s were being reused, but that was in fact a separate bug in my code :sob:.
   
   FWIW, I did manage to work around the issue by creating a new function in `pulsar-client-cpp/lib/c/c_Consumer.cc`:
   
   ```c
   
   void pulsar_consumer_acknowledge_async_id_topic(pulsar_consumer_t *consumer, pulsar_message_id_t *messageId,
                                                   const char *topic, pulsar_result_callback callback,
                                                   void *ctx) {
       std::string t = std::string(topic);
       messageId->messageId.setTopicName(t);
       consumer->consumer.acknowledgeAsync(
           messageId->messageId, std::bind(handle_result_callback, std::placeholders::_1, callback, ctx));
   }
   ```
   
   and then in `pulsar-client-go/pulsar/c_consumer.go`,
   
   ```golang
   
   func (c *consumer) AckIDTopic(msgId MessageID, topic string) error {
   	cTopic := C.CString(topic)
   	defer C.free(unsafe.Pointer(cTopic))
   	C.pulsar_consumer_acknowledge_async_id_topic(c.ptr, msgId.(*messageID).ptr, cTopic, nil, nil)
   	return nil
   }
   ```
   
   The new `AckIDTopic()` does then work, without crashing. However this doesn't really seem to be the right way to solve this issue, so I'm not submitting a PR. Experimental branch is [here](https://github.com/bschofield/pulsar/tree/bschofield/v2.5.0-golang-id-fix) for reference.


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