Reputation: 343
I am newbie and can see one example with one consumer in below github repository, but any ideas how to create multiple consumers for same topic in go lang?
https://github.com/confluentinc/confluent-kafka-go/tree/master/examples
Any consumer factory (to generate N consumers) available in confluent-kafka to read same topic (with partitions)?
Upvotes: 1
Views: 8258
Reputation: 20810
There is an example in the Confluent github repo :
If you want to create multiple consumers for the same topic, there are two scenarios :
1.Create each consumer with different group id.
c1, err := kafka.NewConsumer(&kafka.ConfigMap{
"bootstrap.servers": broker,
"group.id": group1,
"session.timeout.ms": 6000,
"default.topic.config": kafka.ConfigMap{"auto.offset.reset": "earliest"}})
c2, err := kafka.NewConsumer(&kafka.ConfigMap{
"bootstrap.servers": broker,
"group.id": group2,
"session.timeout.ms": 6000,
"default.topic.config": kafka.ConfigMap{"auto.offset.reset": "earliest"}})
Upvotes: 1