参考文献: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()
until len()
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)是等待消息到来的最长时间。