有人知道如何在Python中使用相同的組ID來運行多個消費者嗎? 我試過以下Python中具有相同組ID的多個消費者
a = Consumer({'bootstrap.servers': 'localhost:9092', 'group.id': 'dd1',
'default.topic.config': {'auto.offset.reset': 'smallest'}})
b = Consumer({'bootstrap.servers': 'localhost:9092', 'group.id': 'dd1',
'default.topic.config': {'auto.offset.reset': 'smallest'}})
c = Consumer({'bootstrap.servers': 'localhost:9092', 'group.id': 'dd1',
'default.topic.config': {'auto.offset.reset': 'smallest'}})
a.subscribe([topic_to_read])
b.subscribe([topic_to_read])
c.subscribe([topic_to_read])
running = True
while running:
msg1 = a.poll(timeout=timeout)
msg2 = b.poll(timeout=timeout)
msg3 = c.poll(timeout=timeout)
但是,這是行不通的。 所以我試過使用多處理庫,但我無法使它工作。
你爲什麼說它不工作。你期望什麼把他們放在同一個團隊中的行爲? 您在topic_to_read中有多少個分區? –