Kafka : Use common consumer group to access multiple topics

yes, as long as both consumers subscribe() the the same set of topics (topicA and topicB) the partitions of all topics will be distributed across all consumers.

in your case this would mean that if one of the consumers fails, both topics will be assigned to the surviving consumer.


Absolutely yes. The kafka consumers should monitor both topics and then, kafka will assign the partitions (per topic) to the current active members of the consumer group.

Regardless of having one or multiple partitions on every single topic, the consumers will take charge of monitoring the partitions per topic whenever a consumer failure happens in the same group. When a failure happens, the Kafka will always trigger the re-balancing process in order to distribute the partitions to the remaining active consumers of the group and as a consequence, the work will continue running on that topics.


I'm surprised that all answers with "yes" are wrong. I just tested it and having the same group.id for consumers for different topic works well and does NOT mean that they share messages, because for Kafka the key is (topic, group) rather than just (group). Here is what I did:

  1. created 2 different topics T1 and T2 with 2 partitions in each topic
  2. created 2 consumers with the same group xxx
  3. assigned consumer C1 to T1, consumer C2 to T2
  4. produced messages to T1 - only consumer C1 assigned to T1 processed them
  5. produced messages to T2 - only consumer C2 assigned to T2 processed them
  6. killed consumer C1 and repeated 4-5 steps. Only consumer C2 processed messages from T2
  7. messages from T1 were not processed

Conclusion: Consumers with the same group name subscribed to different topics will NOT consume messages from other topics, because the key is (topic, group)