简体   繁体   English

如何使用Spring DSL使骆驼主线程保持活动状态

[英]How to keep main Camel thread alive with Spring DSL

I am developing my first real Camel-based Java app and am running into a bizarre, complicated issue that I believe is a result of the main Camel thread dying/finishing. 我正在开发我的第一个真正的基于Camel的Java应用程序,并且遇到了一个奇怪的,复杂的问题,我认为这是Camel主线程快要死掉/完成的结果。

Basically, the route itself consists of just a few processors, and one of the processors does some heavy computations that take 20 - 25 seconds to finish. 基本上,路由本身仅包含几个处理器,并且其中一个处理器进行大量的计算,需要20到25秒才能完成。 The app as a whole is terminating without throwing any exceptions/errors/log statements are any other indication that something went wrong, and is dying while doing these expensive computations. 整个应用程序在不引发任何异常/错误/日志语句的情况下终止,这是其他任何迹象表明存在问题,并且在进行这些昂贵的计算时会死掉。

I'm not looking for anybody to diagnose my problem, I just want a way to force the Camel route to stay alive, because what I believe is happening is that the main Camel thread is reaching the end of the route, stopping it, and shutting down the application. 我不是在寻找任何人来诊断我的问题,我只是想一种方法来强制Camel路线保持存活,因为我认为正在发生的事情是Camel主线程到达了该路线的尽头,将其停止,并且关闭应用程序。 I'd like to force the main Camel thread to stay alive for, say, 60 seconds, to see if I can at least rule it out as a factor. 我想强迫骆驼主线程存活60秒,以查看是否至少可以排除它。

If using the Java DSL, I'd just throw the following on to the end of my route: 如果使用Java DSL,我将在路由的末尾添加以下内容:

.to(new Processor() {
    @Override
    public void process(Exchange exchange) {
        try {
            Thread.sleep(60000);
        } catch(Throwable t) {
            // ...
        }
    }
})
.to("direct:endOfRoute");

I'm using Spring DSL (XML) - any ideas? 我正在使用Spring DSL(XML)-有什么想法吗? Thanks in advance! 提前致谢!

a route finishing will not terminate your Camel application/context, you just need to make sure that the container that instantiates the context keeps running... 路由完成不会终止您的Camel应用程序/上下文,您只需要确保实例化上下文的容器保持运行即可...

see http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html 参见http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html

that said, to your specific question, you can use the the delayer EIP to introduce an explicit delay in your route 也就是说,对于您的特定问题,您可以使用延迟器EIP在您的路线中引入明确的延迟

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM