Apache Camel的Spring启动应用程序在启动后立即关闭

问题描述 投票:0回答:1

我的应用程序是使用Spring Boot和Apache Camel用Java编写的。在我的Windows开发环境中运行时,它会启动并运行良好。但是当在我的Open Shift测试环境中运行时,应用程序正常启动然后关闭,就好像我按下了CTRL + C.

在线的一些建议是添加或删除某些依赖项。这已经在我的Maven pom.xml中完成了:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
    </exclusion>
  </exclusions>
</dependency>

以下是我日志中最相关的部分:

2019-04-23T12:34:37.009+0000 INFO  [main] [org.apache.camel.spring.SpringCamelContext] [] [] [] [] [] [] [] [] [] [] Route: myservice-localhost started and consuming from: direct://myservice-localhost
2019-04-23T12:34:37.011+0000 INFO  [main] [org.apache.camel.spring.SpringCamelContext] [] [] [] [] [] [] [] [] [] [] Route: route1 started and consuming from: direct://myservice-myroute
2019-04-23T12:34:37.016+0000 INFO  [main] [org.apache.camel.spring.SpringCamelContext] [] [] [] [] [] [] [] [] [] [] Route: myservice started and consuming from: servlet:/myservice/%7BcompanyID%7D
2019-04-23T12:34:37.021+0000 INFO  [main] [org.apache.camel.spring.SpringCamelContext] [] [] [] [] [] [] [] [] [] [] Total 9 routes, of which 9 are started
2019-04-23T12:34:37.041+0000 INFO  [main] [org.apache.camel.spring.SpringCamelContext] [] [] [] [] [] [] [] [] [] [] Apache Camel 2.21.0 (CamelContext: OBGW-Camel) started in 4.165 seconds
2019-04-23T12:34:37.289+0000 INFO  [main] [org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainer] [] [] [] [] [] [] [] [] [] [] Undertow started on port(s) 8090 (http)
2019-04-23T12:34:37.294+0000 INFO  [main] [org.springframework.context.support.DefaultLifecycleProcessor] [] [] [] [] [] [] [] [] [] [] Starting beans in phase 0
2019-04-23T12:34:37.415+0000 INFO  [main] [org.apache.camel.component.servlet.CamelHttpTransportServlet] [] [] [] [] [] [] [] [] [] [] Initialized CamelHttpTransportServlet[name=CamelServlet, contextPath=]
2019-04-23T12:34:37.416+0000 INFO  [main] [org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainer] [] [] [] [] [] [] [] [] [] [] Undertow started on port(s) 8080 (http)
2019-04-23T12:34:37.422+0000 INFO  [main] [com.mycompany.Application] [] [] [] [] [] [] [] [] [] [] Started Application in 21.385 seconds (JVM running for 22.759)
2019-04-23T12:34:49.811+0000 INFO  [Thread-2] [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] [] [] [] [] [] [] [] [] [] [] Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5387f9e0: startup date [Tue Apr 23 12:34:17 UTC 2019]; root of context hierarchy
2019-04-23T12:34:49.812+0000 INFO  [Thread-2] [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] [] [] [] [] [] [] [] [] [] [] Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@630390b9: startup date [Tue Apr 23 12:34:31 UTC 2019]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5387f9e0
2019-04-23T12:34:49.846+0000 INFO  [Thread-2] [org.springframework.context.support.DefaultLifecycleProcessor] [] [] [] [] [] [] [] [] [] [] Stopping beans in phase 2147483647
2019-04-23T12:34:49.846+0000 INFO  [Thread-2] [org.apache.camel.spring.SpringCamelContext] [] [] [] [] [] [] [] [] [] [] Apache Camel 2.21.0 (CamelContext: OBGW-Camel) is shutting down
2019-04-23T12:34:49.852+0000 INFO  [Thread-2] [org.apache.camel.impl.DefaultShutdownStrategy] [] [] [] [] [] [] [] [] [] [] Starting to graceful shutdown 9 routes (timeout 300 seconds)
2019-04-23T12:34:49.872+0000 INFO  [Camel (OBGW-Camel) thread #1 - ShutdownTask] [org.apache.camel.impl.DefaultShutdownStrategy] [] [] [] [] [] [] [] [] [] [] Route: myservice shutdown complete, was consuming from: servlet:/myservice/%7BcompanyID%7D
2019-04-23T12:34:49.872+0000 INFO  [Camel (OBGW-Camel) thread #1 - ShutdownTask] [org.apache.camel.impl.DefaultShutdownStrategy] [] [] [] [] [] [] [] [] [] [] Route: route1 shutdown complete, was consuming from: direct://myservice-myroute

Open语音环境中的所有内容都完全相同,直到语句Started Application开始关闭时。

java spring-boot apache-camel openshift
1个回答
1
投票

通常,对spring-boot-starter-web的依赖足以使进程保持正常运行。

但是,您使用Undertow作为Camel的HTTP服务器而不是Spring Boot的标准Tomcat。因此你可能需要放

camel.springboot.main-run-controller=true

进入您的应用程序属性(如评论所示)。这也在文档的Camel SpringBoot page中提到。

© www.soinside.com 2019 - 2024. All rights reserved.