We are making a Kafka Queue into which messages are being published from source system. Now multiple consumers can connect to this queue to read messages.
While doing this the consumers have to specify a groupId based on which the messages are distributed , if two apps have the same groupId both of them won't get the messages.
Is there a way i can enforce every app. to have a unique consumer group Id?
Kafka is not a naming registry, but there are many other strategies that you might use to assign unique group names without a coordinator:
Even though I used uuid suffix for group id for some time it looked weird and polluted consumer list in kafka tool. For me random group id was needed for topics that kind of needed everywhere e.g. currency rates. Let say I have k8s deployment with 3 pods and each one needed latest rates to serve data for players in different currencies. Then I was reading doc again
group.id
A unique string that identifies the consumer group this consumer belongs to. This property is required if the consumer uses either the group management functionality by using subscribe(topic) or the Kafka-based offset management strategy.
and realised that for this use case you don't need neither group management (because this topic is not really scaled if you need it everywhere) nor offset management (because with random group kafka it is always new group with no offsets stored). So I decided to use single partition topic (i.e. partition 0) and assign(0) explicitly instead of subscribe() in which case you can skip group.id property at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With