【发布时间】: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