![](/img/trans.png)
[英]How to consume from Kafka topic in multiple goroutines, using Sarama?
[英]How to get multiple subscriptions in sarama
有人知道如何使用 Sarama 在 Apache Kafka 中制作多訂閱主題
我有一個簡單的消費者,我需要訂閱三個不同的主題
topic := "Payments" // need to be "Payments","System","Orders"
consumer, err := master.ConsumePartition(topic, 0, sarama.OffsetOldest)
if err != nil {
panic(err)
}
Sarama Cluster為我提供了幫助
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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.