Versions Compared

Key

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

...

  • close(0, TimeUnit.MILLISECONDS) - do not wait, fail all the incomplete requests and close the producer.
  • 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, wait for sender thread to complete and close producer.
  • close(-1, TimeUnit.MILLISECONDS) - IllegalArgumentException will be thrown.

...

When close(positive, TimeUnit.MILLISECONDS) is called, it will try to do a normal close first. If the normal close did not finish before timeout, it then close the producer forcefully. It will also wait the sender thread to finish.

If sender thread calls close(), it will block forever. So if a close() call is called from sender thread, an error message will be put in the log and sender thread will be blocked forever. This is to:

...