kafka producer.poll producer.flush consumer.poll的区别


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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM