Skip to content

Commit d9f9363

Browse files
committed
Ensure threads are running when calling shutdown
Similar to the previous commit, if a worker thread unexpectedly dies with unhandled messages in its queue and then we try to call `shutdown`, those messages won't be handled unless `produce` is called in the future (in which case the worker thread will read the `shutdown` message enqueued here and then exit again). With this change we will restart the worker thread so it can receive the `shutdown` message.
1 parent 2d26a53 commit d9f9363

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/kafka/async_producer.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ def deliver_messages
144144
# @see Kafka::Producer#shutdown
145145
# @return [nil]
146146
def shutdown
147+
ensure_threads_running!
148+
147149
@timer_thread && @timer_thread.exit
148150
@queue << [:shutdown, nil]
149151
@worker_thread && @worker_thread.join

0 commit comments

Comments
 (0)