Read the FAQ first: https://github.com/edenhill/librdkafka/wiki/FAQ
IMPORTANT: Always try to reproduce the issue on the latest released version (see https://github.com/edenhill/librdkafka/releases), if it can't be reproduced on the latest version the issue has been fixed.
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 librdkafkawith a console consumer its very easy to set, how can we do the same when using rdkafka client
I'm not quite sure exactly what you are trying to accomplish here based solely on your comment. But if you are looking for a librdkafka equivalent of the java console consumer you should try out kafkacat.
If the broker is configured to choose a partition based on the message supplied key.
Then in the message we must supply that key other wise broker rejects the message.
console producer supports supplying the property "parse.key" and "key.separator" .
./kafka-console-producer.sh --broker-list
My Question here is how can i set these two properties when i am not using console producer and i am using RDkafka based c++ client.
I checked in the supported configuration in rdkakfa https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md
It does not support any of the config property "parse.key" and "key.separator" .
So how will i set these property in my c++ program to make the same effect as passing
--property "parse.key=true" --property "key.separator=:" to the console producer.
Thanks
Thanks for clarifying,
Kafkacat, linked previously, includes a flag, -K which you can use to configure your key value delimiter.
https://github.com/edenhill/kafkacat/blob/master/kafkacat.c#L959
You pass the key and the message payload as separate strings to the rdkafka API. (The RdKafka::Producer::produce method has a const std::string * key parameter.)
If you are writing your own C++ client, you will need to write a method to parse the key from the message. If you are using kafkacat, see above. Otherwise, you need to refer to the author of the C++ client you are using.
It's worth noting these are not client properties for either language. The key.separator and parse.key flags are specific to the console producer(Scala) just as -k is specific to kafkacat(librdkafka derived). You will need to write your own parser for either language if you wish to incorporate the logic into your own code.
Thanks a lot rnpridgeon and rolandyoung for your help.
I tried the minimal change, calling "key" supported method in my client of RdKafka::Producer::produce
and it works !!!
Thanks
Most helpful comment
You pass the key and the message payload as separate strings to the rdkafka API. (The RdKafka::Producer::produce method has a
const std::string * keyparameter.)If you are writing your own C++ client, you will need to write a method to parse the key from the message. If you are using kafkacat, see above. Otherwise, you need to refer to the author of the C++ client you are using.