https://cwiki.apache.org/confluence/display/KAFKA/KIP-15+-+Add+a+close+method+with+a+timeout+in+the+producer
As a short summary, the new interface will be as following: Close(Long Timeout, TimeUnit timeUnit) 1. When timeout > 0, it will try to wait up to timeout for the sender thread to complete all the requests, then join the sender thread. If the sender thread is not able to finish work before timeout, the method force close the producer by fail all the incomplete requests and join the sender thread. 2. When timeout = 0, it will be a non-blocking call, just initiate the force close and DOES NOT join the sender thread. If close(timeout) is called from callback, an error message will be logged and the producer sender thread will block forever.