i have implemented spring-kafka
consumer application.
i wants consumer application graceful shutdown.
the current consumer application is terminated with the Linux command kill -9 pid
i am using @KafkaListener
annotation now.
if i quit the Spring boot app, i want to reliably close the consumer, what should i do ?
i've been using @Predestory
to reliably exit the spring boot app, but i'm not quite sure if this has anything to do with it.
kill -9
is like the death star
Some of the more commonly used signals:
1 HUP (hang up)
2 INT (interrupt)
3 QUIT (quit)
6 ABRT (abort)
9 KILL (non-catchable, non-ignorable kill)
14 ALRM (alarm clock)
15 TERM (software termination signal)
The default kill signal SIGTERM (15)
kill <pid>
Boot will shut down everything gracefully; it registers a shutdown hook, which can't intercept a kill -9
.
If you want to stop a single consumer, just call stop()
on the listener container.
Note that when you call stop()
the container will process all records that have been fetched from poll()
until that point, before the container shuts down.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With