Kafka Exception WakeupException
org.apache.kafka.common.errors.WakeupException
Non-retriable
Consumer
Exception used to indicate preemption of a blocking operation by an external thread. For example, wakeup can be used to break out of an active Duration), which would raise an instance of this exception.
Common Causes
- Another thread called consumer.wakeup() to interrupt a blocking poll() — this is the standard, intentional way to break out of the poll loop for a clean shutdown
- Treated as an error when it is actually the expected control-flow signal for stopping a consumer
Solutions
- Catch WakeupException around poll(), then break the loop and call consumer.close() in a finally block — do not log it as an error during planned shutdown
- Only ignore it when shutdown was requested; if wakeup() was not called intentionally, investigate which thread triggered it
- Register a shutdown hook that calls consumer.wakeup() (not consumer.close()) from the signal thread, since close() is not safe from another thread
Example Stack Trace
org.apache.kafka.common.errors.WakeupException
at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.maybeTriggerWakeup(ConsumerNetworkClient.java:514)
at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1230)Related
Related Consumer exceptions: CommitFailedException · CoordinatorLoadInProgressException · CoordinatorNotAvailableException · FencedInstanceIdException · FencedMemberEpochException · GroupMaxSizeReachedException · IllegalGenerationException · InvalidGroupIdException
Hitting
WakeupException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.