我在PC上本地运行kafka。我在客户控制台中看到以下错误消息。我们如何捕获记录到控制台的消息
consumed message None: msg1: 0: first_topic: 0: None
consumed message None: msg2: 1: first_topic: 0: None
no message received by consumer
no message received by consumer
%4|1603348021.170|SESSTMOUT|rdkafka#consumer-1| [thrd:main]: Consumer group session timed out (in join-state started) after 10005 ms without a successful response from the group coordinator (broker 0, last error was Success): revoking assignment and rejoining group
no message received by consumer
from confluent_kafka import Consumer
def consume():
c = Consumer({"bootstrap.servers": "localhost:9092",
"group.id": "group1",
"enable.auto.commit": False,
"auto.offset.reset": "earliest",
"max.poll.interval.ms": 30000,
"session.timeout.ms": 10000,
"heartbeat.interval.ms": 15000
})
c.subscribe(["first_topic"])
while True:
message = c.poll(1.0)
if message is None:
print("no message received by consumer")
elif message.error() is not None:
print(f"error from consumer {message.error()}")
else:
print(f"consumed message {message.key()}: {message.value().decode('utf-8')}: {message.offset()}: {message.topic()}: {message.partition()}: {message.headers()}")
time.sleep(10)