THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
- Sometimes, user will want to close a producer wiithin within a bounded time to avoid blocking on producer.close() for too long.
- One specific use case of 1) is that in some scenarios, user will want to close the produce immediately and fail all the unsent messages in RecordAccumulator. Some examples are:
- In mirror maker, if a send failed, we don't want to continue sending messages in RecordAccumulator to avoid reordering.
- For people who are using deployment tools, a service is expected to stop in given time. In that case people might want to have a bounded time to shutdown producer.
...
- The close(timeout) should work when called from a user caller thread or the internal sender thread.
- In sender thread only close(-1, TimeUnit.MILLISECONDS) should be called because:
- close() or close(0, TimeUnitMILLISECONDSTimeUnit.MILLISECONDS) should not be called because that will make producer block forever.
- close(500, TimeUnit.MILLISECONDS) has the same effect as close(-1, 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.
...