如何在萨拉玛获得多个订阅

chy5wohz  于 2021-06-06  发布在  Kafka
关注(0)|答案(1)|浏览(460)

有人知道如何使用sarama在apachekafka中创建多个订阅主题
我有一个简单的消费者,我需要订阅三个不同的主题

topic := "Payments" // need to be "Payments","System","Orders"

consumer, err := master.ConsumePartition(topic, 0, sarama.OffsetOldest)
if err != nil {
    panic(err)
}
uurv41yg

uurv41yg1#

萨拉玛帮了我

brokers := []string{"127.0.0.1:9092"}
    topics := []string{"my_topic", "other_topic"}
    consumer, err := cluster.NewConsumer(brokers, "my-consumer-group", topics, config)
    if err != nil {
        panic(err)
    }
    defer consumer.Close()

相关问题