Read the FAQ first: https://github.com/edenhill/librdkafka/wiki/FAQ
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.
// 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)
.......
}
IMPORTANT: We will close issues where the checklist has not been completed.
Please provide the following information:
<REPLACE with e.g., v0.10.5 or a git sha. NOT "latest" or "current"><REPLACE with e.g., 0.10.2.3><REPLACE with e.g., message.timeout.ms=123, auto.reset.offset=earliest, ..><REPLACE with e.g., Centos 5 (x64)>debug=.. as necessary) from librdkafkathe msq_opaque value specified in rd_kafka_produce is available via the _private field in rd_kafka_message_t.
wonderful answer
Most helpful comment
the
msq_opaquevalue specified inrd_kafka_produceis available via the_privatefield inrd_kafka_message_t.