An available library is sarama (or its expansion sarama-cluster) however no consumer group example are provided, not in sarama nor in sarama-cluster.
I do not understand the API. May I have an example of creating a consumer group for a topic?
An available library is sarama (or its expansion sarama-cluster) however no consumer group example are provided, not in sarama nor in sarama-cluster.
I do not understand the API. May I have an example of creating a consumer group for a topic?
The consumer group is specified by the second argument of the cluster consumer "constructor". Here's a very basic sketch:
import (
"github.com/Shopify/sarama"
"github.com/bsm/sarama-cluster"
)
conf := cluster.NewConfig()
// add config values
brokers := []string{"kafka-1:9092", "kafka-2:9092"}
group := "Your-Consumer-Group"
topics := []{"topicName"}
consumer := cluster.NewConsumer(broker, group, topics, conf)
And so you'll have a consumer belonging to the specified consumer group.