Различаются между KafkaProducer.close () и KafkaProducer.flush () - PullRequest
0 голосов
/ 08 мая 2019

Глядя на документацию, я не уверен, что понимаю разницу между использованием close () и flush () .

Это документ для флеша ()

 * Invoking this method makes all buffered records immediately available to send (even if <code>linger.ms</code> is
 * greater than 0) and blocks on the completion of the requests associated with these records. The post-condition
 * of <code>flush()</code> is that any previously sent record will have completed (e.g. <code>Future.isDone() == true</code>).
 * A request is considered completed when it is successfully acknowledged
 * according to the <code>acks</code> configuration you have specified or else it results in an error.

И документ для закрытия ():

 * This method waits up to <code>timeout</code> for the producer to complete the sending of all incomplete requests.
 * If the producer is unable to complete all requests before the timeout expires, this method will fail
 * any unsent and unacknowledged records immediately.

Означает ли это, что:

  1. Если я использую close () и в буфере в памяти ожидают записи, они даже не будут предприняты (по сравнению с flush, который попытается отправить их)?
  2. Если я использую flush (), он может заблокировать «навсегда», если повторные попытки велики? В то время как с close () у меня есть верхняя граница как долго это займет?

Полагаю, если я прав в 1., продюсер с acks = 0 получит подтверждение для записи, которую даже нельзя пытаться опубликовать, если она "не повезет", чтобы ее поместили в очереди памяти и сразу после вызова close ().

...