Closed jlambert121 closed 8 months ago
It is not recommended because it is not fully predictable
old but still valid: https://blog.arkency.com/2013/06/are-we-abusing-at-exit/
I recommend using given framework native exit capabilities. It no native capabilities are present and you know what you are doing at exit should be sufficient.
Older versions of karafka rdkafka would occasionally crash on at exit close but I did not see this issue for years now so you should be good.
Perfect - thank you for the response and clarification!
The FAQ states that
at_exit
is not recommended for shutting downWaterDrop
, but does not give any context as to why. Would you be able to provide more context as to why this recommendation?The specific use case we are running into is specifically with sidekiq. We are unable to send a
USR1
signal to just quiet the queue because of limitations within our environment, just aSIGTERM
. AddingKarafka.producer.close
to the:shutdown
event runs it immediately when theSIGTERM
is received rather than as sidekiq is exiting meaning some jobs finishing up no longer have a connection from the producer to write to. My solution was going to be to wrap the shutdown withat_exit
, but wanted to understand any concerns with this solution.