Search code examples
goapache-kafkaconfluent-platformlibrdkafka

how to create consumer group with multiple consumers in confluent-kafka-go?


As i'm new to Go and kafka , i need to implement consumer groups using confluent-kafka-go module. can anyone help me out?

Thanks in advance


Solution

  • With confluent-kafka-go, you just need to set group.id in your consumer configuration to have it join/create a group.

    For example:

    c, err := kafka.NewConsumer(&kafka.ConfigMap{
            "bootstrap.servers": "localhost:9092",
            "group.id":          "my-group"})
    

    One of the samples demonstrates that: https://github.com/confluentinc/confluent-kafka-go/blob/master/examples/consumer_example/consumer_example.go