Librdkafka: null from msg_opaque in delivery_report_callback

Created on 25 Jul 2018  路  2Comments  路  Source: edenhill/librdkafka

Read the FAQ first: https://github.com/edenhill/librdkafka/wiki/FAQ

Description

Setting msg_opaque in rd_kafka_produce but got null value from delivery_report_callback.

We implemented a test code in one x++ source file that defines a char pointer as a global variable. We passed that global variable as the value to msg_opaque param when calling rd_kafka_produce. IN the callback we set up we got the null value back.

Code Snippet

// defined as a global variable in a source file
char *opaqueVal = "Opaque Value\0";
.......
bool sendEventMessage(const string topicName, const string messagePayload, int *errCode, string *errDesc) {
.......
rd_kafka_produce(pTopic, RD_KAFKA_PARTITION_UA, RD_KAFKA_MSG_F_FREE, (char *)messagePayload.c_str(), strlen(messagePayload.c_str()), NULL, 0, opaqueVal)
.......
}

Checklist

IMPORTANT: We will close issues where the checklist has not been completed.

Please provide the following information:

  • [x] librdkafka version (release number or git tag): <REPLACE with e.g., v0.10.5 or a git sha. NOT "latest" or "current">
  • [x] Apache Kafka version: <REPLACE with e.g., 0.10.2.3>
  • [x] librdkafka client configuration: <REPLACE with e.g., message.timeout.ms=123, auto.reset.offset=earliest, ..>
  • [x] Operating system: <REPLACE with e.g., Centos 5 (x64)>
  • [x] Provide logs (with debug=.. as necessary) from librdkafka
  • [x] Provide broker log excerpts
  • [ ] Critical issue
question

Most helpful comment

the msq_opaque value specified in rd_kafka_produce is available via the _private field in rd_kafka_message_t.

All 2 comments

the msq_opaque value specified in rd_kafka_produce is available via the _private field in rd_kafka_message_t.

wonderful answer

Was this page helpful?
0 / 5 - 0 ratings