java - 如何优雅地关闭 spring-kafka 消费者应用程序
问题描述
我已经实现了spring-kafka
消费者应用程序。
我希望消费者应用程序正常关闭。
当前的消费者应用程序使用 Linux 命令终止kill -9 pid
我现在正在使用@KafkaListener
注释。
如果我退出 Spring Boot 应用程序,我想可靠地关闭消费者,我该怎么办?
我一直在使用@Predestory
可靠地退出 spring boot 应用程序,但我不太确定这是否与它有关。
解决方案
kill -9
就像死星
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)
默认终止信号 SIGTERM (15)
kill <pid>
启动会优雅地关闭一切;它注册了一个关闭钩子,它不能拦截一个kill -9
.
推荐阅读
- html - SVG 波纹效果:没有获得正确的波纹效果动画
- python - 使用旧字典中长度最长的键和值制作新字典,如何同时增加变量?
- javascript - 将数据传递给 Electron 中的模态
- javascript - 为什么 redux-form 不将选项字段中的值作为提交函数中的 prop 传递?
- laravel - VueJs | 拉拉维尔 | Vuejs函数在循环中不起作用
- javascript - Leaflet R中的不同颜色addPolylines
- java - 将我的应用程序连接到 SQLite 数据库 - 如何?
- html - HTML5 Canvas DrawImage Safari 12.0 错误(在 iOS 12.1/Mac OS Mojave 上测试)
- c# - 从 lambda 返回数组索引但抛出 IndexOutOfRangeException
- c - strcmp() 没有返回它应该返回的内容