Приложение весенней загрузки с Apache Camel закрывается сразу после запуска - PullRequest
0 голосов
/ 23 апреля 2019

Мое приложение написано на Java с использованием Spring Boot и Apache Camel. При запуске в моей среде разработки 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 Shift все точно так же, пока оператор Started Application не начнет отключаться.

1 Ответ

1 голос
/ 23 апреля 2019

Обычно для поддержания и работы процесса достаточно зависимости от spring-boot-starter-web.

Однако вы используете Undertow в качестве HTTP-сервера Camel вместо стандартного Spring Boot Tomcat. Поэтому вам, вероятно, нужно поставить

camel.springboot.main-run-controller=true

в свойствах вашего приложения (как уже предложено в комментарии). Это также упоминается на странице Camel SpringBoot документации.

...