gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 18:42:22 26 4
gpt4 key购买 nike

我有一个独立的 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com