【问题标题】:How to avoid Springboot Camel Route shut down every day for hang up signal at specific time如何避免Springboot Camel Route每天因特定时间挂断信号而关闭
【发布时间】:2020-01-24 17:36:53
【问题描述】:

我有一个带有 Apache Camel 2.24 camelroutes 设置的独立 springboot 应用程序。预计将 24x7 运行应用程序,并且永远不会出现故障。通过camel REST DSL公开为REST API的服务。

**

请帮助如何避免camel springboot应用程序关闭而没有关闭java进程 每天自动

**

我已经使用 nohup java -jar 命令从 Udeploy 执行了 springboot jar 来部署以避免挂断中断。

应用程序每天在特定时间收到 HangupInterceptor 消息,用于挂断和停止主实例。这会优雅地关闭我的 Camel 路由,关闭 spring camel 上下文,最后销毁 camelhttptransport servlet。

当我使用 ps -ef | 检查时,springboot 应用程序的 jvm java 进程最终也被 Camel 上下文强制关闭/终止,不再运行 grep java

日志:

[ngupInterceptor] o.a.c.m.MainSupport$HangupInterceptor : Received hang up - stopping the main instance.
[ngupInterceptor] o.a.camel.spring.SpringCamelContext : Apache Camel 2.24.0 (CamelContext: Camel1) is shutting down
[ngupInterceptor] o.a.camel.impl.DefaultShutdownStrategy : Starting to graceful shutdown 2 routes(timeout 300 seconds)
[ - ShutdownTask] o.a.camel.impl.DefaultShutdownStrategy : Route: routename1 shutdown complete, was consuming from: direct://r1
[ - ShutdownTask] o.a.camel.impl.DefaultShutdownStrategy : Route: routename2 shutdown complete, was consuming from: direct://r2
[ngupInterceptor] o.a.camel.impl.DefaultShutdownStrategy : Graceful shutdown of 2 routes completed in 0 seconds
[ Thread-7] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService ’applicationTaskExecutor’
[ngupInterceptor] o.a.camel.main.MainLifecycleStrategy : CamelContext: Camel1 has been shutdown, triggering shutdown of the JVM
[ngupInterceptor] o.a.camel.spring.SpringCamelContext : Apache Camel 2.24.0 (CamelContext: Camel1) uptime 6 hours 10 minutes
[ngupInterceptor] o.a.camel.spring.SpringCamelContext : Apache Camel 2.24.0 (CamelContext: Camel1) is shutdown in 0.052 seconds
[ Thread-7] o.a.c.c.s.CamelHttpTransportServlet : Destroyed CamelHttpTransportServlet[Servlet]

application.properties 文件包含在其中

camel.springboot.main-run-controller=true

pom.xml 包含此文件

<dependency>   
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-started-web</artifactId>
</dependency>

【问题讨论】:

  • 谁在发送挂断?并发布您的代码,而不仅仅是它的 sn-p
  • 我无法追踪它,因为日志没有显示它。我假设它可能来自执行 java -jar 命令的 Udeploy 服务器或来自启动 SIGHUP 的 Unix 服务器 jvm。
  • 从未听说过 uDeploy,祝你好运
  • 我有通常的 springbootApplicatio 主类,其中 scanBasePackages 没有什么。我使用 Apache Camel 的依赖项 camel-spring-boot-starter。它自动识别路线。路由是在一个类中定义的,该类使用@Component 扩展了 routebuilder。你能告诉我你有兴趣看哪段代码吗?路线是如何定义的?
  • UDeploy 是 UrbanCode Deploy

标签: java spring spring-boot apache-camel spring-camel


【解决方案1】:

HangupInterceptor 可以通过在 application.properties 中设置 camel.main.hangup-interceptor-enabled=false 来禁用。

【讨论】:

  • 这部分是camel 3.0.x的吗?
  • 我目前在 2.24。我还没有迁移。
  • 你是对的,这是在 3.0.0 中引入的(对不起,我在看 master 分支)。目前我看不到如何在 2.24 中设置它的简单方法。迁移到 3.x 是个好主意,因为 2.24.x 将不再更新(2.24.3 是最后计划的补丁),并且计划仅在今年年底之前支持 2.25.x。
【解决方案2】:

发现一些其他应用程序 sh 脚本在所有 java pid 上运行了 kill -9 命令来停止应用程序。找到并修复脚本以避免杀死springboot应用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-11
    • 2018-07-07
    • 2020-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-11
    • 1970-01-01
    相关资源
    最近更新 更多