kafka producer.poll producer.flush consumer.poll的區別
阿新 • • 發佈:2021-07-01
參考文獻:https://docs.confluent.io/current/clients/confluent-kafka-python/index.html#consumer
- Producer.poll(timeout)
timeout(float) – Maximum time to block waiting for events. (Seconds)
Polls the producer for events and calls the corresponding callbacks (if registered).
- Producer.flush()
Wait for all messages in the Producer queue to be delivered. This is a convenience method that calls poll()
untillen()
is zero or the optional timeout elapses.
- Producer.poll()和Producer.flush()的區別:
flush確保所有meg都傳送給broker,對poll的不停呼叫直到len(Number of messages and Kafka protocol requests waiting to be delivered to broker)為0.
- Consumer.poll(timeout):
Consume messages, calls callbacks and returns events.
作用是取資料,傳入的引數:timeout(float) – Maximum time to block waiting for message, event or callback. (Seconds)是等待訊息到來的最長時間。