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