java - 如何避免Springboot Camel Route每天在特定时间挂断信号而关闭

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

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

**

Please help how to avoid the camel springboot application from shutting down and not shut down the java process automatically every day

**

我已经使用 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>

最佳答案

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

关于java - 如何避免Springboot Camel Route每天在特定时间挂断信号而关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59901255/

相关文章:

java - 表达式的非法开始 - for 循环

java - com.springboot.todoController.TodoController 中的字段 todoService 需要类型为 'com.springboot.todo.TodoService' 的 bean,但无法找到

java - Hibernate DetachedQuery 和 Spring 的 HibernateTemplate with Restriction 给出了错误的结果

java - 如何使用jsp中的超链接将文本框值传递到下一页

java - android:如何将位图数组合并到一个位图中?

java - Java中多线程的实现

json - 使用 JacksonJson 动态忽略属性

json - Scala、Json 和 Spring Boot Rest

java - 如何在 Spring Boot 中将 POST 请求从一个 Web 应用程序正确转发到另一个 Web 应用程序?

java - Log4J2 属性替换 - 使用外部属性文件