2017-02-01 18:07
浏览 1.8k


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?

图片转代码服务由CSDN问答提供 功能建议

可用库为 sarama (或其扩展名 sarama-cluster ),但是没有 提供了消费者组示例,但未在 sarama 和< a href =“” rel =“ nofollow noreferrer”> sarama-cluster 。

我愿意 不了解API。 我可以举一个为主题创建消费者组的示例吗?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • doushoubu5360 2017-02-01 22:12

    The consumer group is specified by the second argument of the cluster consumer "constructor". Here's a very basic sketch:

    import (
    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.

    解决 无用
    打赏 举报

相关推荐 更多相似问题