- When a task is scheduled for shutdown, the framework wakes up the consumer for that task.
- As is noted in the Javadocs for that method, “If no thread is blocking in a method which can throw org.apache.kafka.common.errors.WakeupException, the next call to such a method will raise it instead.”
- It just so happens that, if the framework isn’t in the middle of a call to the consumer and then the task gets stopped, the next call the framework will make on the consumer may be to commit offsets, which will immediately throw a WakeupException.
- Currently, the framework handles this by immediately retrying the offset commit until it either throws a different exception or succeeds, and then throwing the original WakeupException. If this synchronous commit of offsets occurs during task shutdown (as opposed to in response to a consumer rebalance), it's unnecessary to throw the WakeupException back to the caller, and can cause alarming ERROR-level messages to get logged by the worker.