Optimal scenario for a long-living producer with/without delivery-callback #3839
-
I have questions regarding the optimal use of the producer once in a Without delivery-callback:Is it generally mandatory to call poll() here? The application is Is it possible to omit poll() altogether here if you have NOT registered With delivery-callback:Assuming that poll() flushes, how often should poll() be called ? Time bound and Maybe you can provide 2 optimal scenarios, one |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you don't register any callbacks (dr_msg_cb, error_cb, stats_cb, etc) then you don't need to call poll(). But not having a delivery report callback (dr_msg_cb) means you will have no way of knowing if your messages were successfully produced or not, which is effectively equivalent to not produce():ing the messages at all - in drastical terms - so we highly advice against this approach. As for poll() overhead; you don't need to call it once for each message produced, in practice you only need to call it when |
Beta Was this translation helpful? Give feedback.
If you don't register any callbacks (dr_msg_cb, error_cb, stats_cb, etc) then you don't need to call poll().
But not having a delivery report callback (dr_msg_cb) means you will have no way of knowing if your messages were successfully produced or not, which is effectively equivalent to not produce():ing the messages at all - in drastical terms - so we highly advice against this approach.
As for poll() overhead; you don't need to call it once for each message produced, in practice you only need to call it when
produce()
returnsERR__QUEUE_FULL
, but that will delay error reporting until the queue is full, so I'd recommend calling poll() once per second or every N messages produce()d.