骆驼过程接收挂断信号并正常关闭

时间:2019-01-29 23:15:08

标签: java apache-camel

我有一个骆驼进程,该进程从Azure容器中提取文件并在Azure环境中进行处理。

我希望该过程能够连续运行,但是在随机间隔后会关闭。

日志:

IIS

... 自从使用DefaultShutdownStrategy后,在机上交换完成后就关闭了所有路线。

Spring上下文路由:

CamelHangupInterceptor: INFO (MainSupport.java:87) - Received hang up - stopping the main instance.
CamelHangupInterceptor: DEBUG (Main.java:187) - Stopping Spring ApplicationContext: org.springframework.context.support.ClassPathXmlApplicationContext@47ef968d
2019-01-29 21:39:50,782: main: INFO (MainSupport.java:502) - MainSupport exiting code: 0

骆驼(v 2.20)进程启动并按预期执行,但是在随机间隔进程关闭后。

我看到收到挂断信号,但不确定如何发生。日志显示正常关机。有没有办法从外部进程向Camel进程发送挂断信号?

在我用来停止交换的路由之一中,以强制停止该路由。

- Start with a scheduler for initial delay,
- then <dealy> component to randomly generate time (logic used for scalability to avoid race condition)
- invoking the custom class implementing Process class, which has Azure container url with credentials and fetch the file from container
- then using wireTap component to downloading the file
- finally invoking another class implementing Process class.

更多日志:

 exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);

-路线信息-

 2019-01-29 21:40:17,838: Camel Thread #0 - CamelHangupInterceptor: DEBUG (DefaultExecutorServiceManager.java:363) - Forcing shutdown of ExecutorService: org.apache.camel.util.concurrent.RejectableThreadPoolExecutor@647b9364[Running, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0][WireTap]
    ...
        2019-01-29 21:40:17,840: Camel Thread #0 - CamelHangupInterceptor: DEBUG (RouteService.java:289) - Shutting down services on route: route1
        2019-01-29 21:40:17,841: Camel Thread #0 - CamelHangupInterceptor: DEBUG (BeanComponent.java:72) - Clearing BeanInfo cache[size=1, hits=1, misses=1, evicted=0]
        2019-01-29 21:40:17,849: Camel Thread #0 - CamelHangupInterceptor: DEBUG (SimpleLanguage.java:136) - Clearing simple language predicate cache[size=0, hits=0, misses=0, evicted=0]
        2019-01-29 21:40:17,849: Camel Thread #0 - CamelHangupInterceptor: DEBUG (SimpleLanguage.java:142) - Clearing simple language expression cache[size=4, hits=1, misses=4, evicted=0]
        2019-01-29 21:40:17,849: Camel Thread #0 - CamelHangupInterceptor: DEBUG (DefaultManagementAgent.java:358) - Unregistered MBean with ObjectName: org.apache.camel:context=camelAzureBlobContext,type=routecontroller,name="camelAzureBlobContext"
        2019-01-29 21:40:17,849: Camel Thread #0 - CamelHangupInterceptor: DEBUG (DefaultManagementAgent.java:358) - Unregistered MBean with ObjectName: org.apache.camel:context=camelAzureBlobContext,type=health,name="camelAzureBlobContext"
        2019-01-29 21:40:17,850: Camel Thread #0 - CamelHangupInterceptor: DEBUG (TimerListenerManager.java:128) - Removed TimerListener: org.apache.camel.management.mbean.ManagedCamelContext@473692b
        2019-01-29 21:40:17,850: Camel Thread #0 - CamelHangupInterceptor: DEBUG (DefaultManagementAgent.java:358) - Unregistered MBean with ObjectName: org.apache.camel:context=camelAzureBlobContext,type=context,name="camelAzureBlobContext"
        2019-01-29 21:40:17,850: Camel Thread #0 - CamelHangupInterceptor: INFO (MainLifecycleStrategy.java:44) - CamelContext: camelAzureBlobContext has been shutdown, triggering shutdown of the JVM.
        2019-01-29 21:40:17,850: Camel Thread #0 - CamelHangupInterceptor: DEBUG (DefaultExecutorServiceManager.java:363) - Forcing shutdown of ExecutorService: org.apache.camel.util.concurrent.RejectableThreadPoolExecutor@72b68833[Running, pool size = 1, active threads = 0, queued tasks = 0, completed tasks = 1][ShutdownTask]
        2019-01-29 21:40:17,851: Camel Thread #0 - CamelHangupInterceptor: DEBUG (DefaultInflightRepository.java:183) - Shutting down with no inflight exchanges.
        2019-01-29 21:40:17,851: Camel Thread #0 - CamelHangupInterceptor: DEBUG (DefaultServicePool.java:110) - Stopping service pool: org.apache.camel.impl.SharedPollingConsumerServicePool@13ed066e
        2019-01-29 21:40:17,851: Camel Thread #0 - CamelHangupInterceptor: DEBUG (DefaultServicePool.java:110) - Stopping service pool: org.apache.camel.impl.SharedProducerServicePool@151ab2b9
    ...
    2019-01-29 21:40:17,856: Camel Thread #0 - CamelHangupInterceptor: DEBUG (MBeanInfoAssembler.java:79) - Clearing cache[size=30, hits=12, misses=30, evicted=0]
    2019-01-29 21:40:17,864: Camel Thread #0 - CamelHangupInterceptor: DEBUG (IntrospectionSupport.java:134) - Clearing cache[size=93, hits=192, misses=93, evicted=0]
    2019-01-29 21:40:17,869: Camel Thread #0 - CamelHangupInterceptor: INFO (DefaultCamelContext.java:3575) - Apache Camel 2.20.0 (CamelContext: camelAzureBlobContext) uptime 32 minutes

1 个答案:

答案 0 :(得分:1)

根据日志,您的整个Camel上下文都已关闭。通过您的ROUTE_STOP调用启动上下文关闭的可能性很小。

查看MainSupport.java源,您在日志文件中看到的INFO日志将作为挂断通知挂钩的一部分执行,并由正在进行的JVM Shutdown通知。发生这种情况时,您的JVM也会死掉吗? This documentation说,当SIGINT,SIGTERM或SIGHUP启动JVM异常终止时,将通知挂钩。

如果您可以提供以下内容的答案,也许我们可以调查更多详细信息

  • 骆驼是否正在Web容器中运行?我看到MainSupport.java:)
  • 您使用哪个JVM版本?
  • 它在什么操作系统平台上运行?
  • 当Camel上下文关闭时,JVM是否仍在运行或JVM是否退出?
  • 您在日志文件中看到其他例外了吗?
  • 我们可以将CamelContext关闭与系统资源耗尽事件相关联吗? (例如,内存不足或类似问题)。由于OOMKiller正常关机,因此不太可能是它。

请注意,不要被名称CamelHangupInterceptor所误导,这并不意味着骆驼收到了SIGHUP