Is there a way to identify the group leader in librdkafka ?
As there is no way to pass a custom partition strategy, I am having some hack to serve the purpose. My specific consumer has to be the group leader if not I should exit.
Or is there a way to make sure there is no other consumer running with the current consumer group id ?
Currently the only way you can identify the leader of a consumer group is to enable the cgrp
debug context (set the debug
config property to cgrp
) and then capture logs (with log_cb
or the event API) and match this log line (which may change in future versions):
1591771297.737 RDKAFKA-7-JOINGROUP: rdkafka#consumer-1: [thrd:main]: JoinGroup response: GenerationId 1, Protocol range, LeaderId rdkafka-b5751775-49f4-4ac8-a912-f5800f5bffbe (me), my MemberId rdkafka-b5751775-49f4-4ac8-a912-f5800f5bffbe, 1 members in group: (no error)
The "(me)
" part will only be included if the LeaderId is the same as the MemberId.