Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This call waits some specified time for the producer to close. If the producer did not finish closing before timeout, it close the producer forcefully by failing all the unsent messages.

  • close(-10, TimeUnit.MILLISECONDS) - do not wait, fail all the incomplete requests and close the producer.close(0, TimeUnit.MILLISECONDS) - wait until all the messages are either sent successfully or failed
  • close(10000, TimeUnit.MILLISECONDS) - wait at most 10 seconds for the producer to send pending messages, if messages cannot be sent in 10 seconds, fail the rest of messages and close producer.
  • close(-1, TimeUnit.MILLISECONDS) - IllegalArgumentException will be thrown.

Several addition considerations:

  • The close(timeout) should work when called from a user caller thread or the internal sender thread.
  • In sender thread only close(-10, TimeUnit.MILLISECONDS) should be called because:
    • close() or close(0, TimeUnit.MILLISECONDS) should not be called because that will make producer block forever.
    • close(500, TimeUnit.MILLISECONDS) has the same effect as close(-10, TimeUnit.MILLISECONDS) only except it will block for 500 milliseconds.
  • Because it is possible the close(timeout) is called for multiple times, it has to be idempotent.

...