如何在 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()