3

我有一个骆驼进程(我从命令行运行),它的路线类似于这个:

public class ProfilerRoute extends RouteBuilder {

 @Override
 public void configure() {   
    from("kestrel://my_queue?concurrentConsumers=10&waitTimeMs=500")
        .unmarshal().json(JsonLibrary.Jackson, MyClass.class)
        .process(new Processor() {
                 @Override
                 public void process(Exchange exchange) throws Exception {
                     /* Do the real processing [...] */
                     exchange.getIn().setBody(null);
                 }
        })
        .filter(body().isNotNull())
        .to("file://nowhere");
 }
}

请注意,我在处理完任何消息后都会将其丢弃,这是一个纯粹的消费者进程。

该过程由它自己运行。没有其他进程在队列上写,队列是空的。但是,当我尝试终止该进程时,该进程不会终止。

从日志中我看到以下几行(为了便于阅读而缩进):

[                      Thread-1] MainSupport$HangupInterceptor  INFO  
                                 Received hang up - stopping the main instance.
[                      Thread-1] MainSupport                    INFO
                                 Apache Camel stopping
[                      Thread-1] GuiceCamelContext              INFO
                                 Apache Camel 2.11.1 (CamelContext: camel-1) 
                                 is shutting down
[                      Thread-1] DefaultShutdownStrategy        INFO
                                 Starting to graceful shutdown 1 routes 
                                 (timeout 300 seconds)
[l-1) thread #12 - ShutdownTask] DefaultShutdownStrategy        INFO
                                 Waiting as there are still 10 inflight and 
                                 pending exchanges to complete, 
                                 timeout in 300 seconds.

以此类推,超时减少。在超时结束时,我得到了日志:

[l-1) thread #12 - ShutdownTask] DefaultShutdownStrategy        INFO
                                 Waiting as there are still 10 inflight and 
                                 pending exchanges to complete,
                                 timeout in 1 seconds.
[                      Thread-1] DefaultShutdownStrategy        WARN
                                 Timeout occurred. 
                                 Now forcing the routes to be shutdown now.
[l-1) thread #12 - ShutdownTask] DefaultShutdownStrategy        WARN
                                 Interrupted while waiting during graceful 
                                 shutdown, will force shutdown now.
[                      Thread-1] KestrelConsumer                INFO  
                                 Stopping consumer for 
                                 kestrel://localhost:22133/my_queue?concurrentConsumers=10&waitTimeMs=500

但是这个过程无论如何都不会死(即使我此时试图杀死它)。

我原以为在等待时间之后所有线程都会意识到正在关闭并停止。

我已经阅读了“Graceful Shutdown”文档,但是我找不到可以解释我所面临的行为的东西。

从日志中可以看出,我使用的是 2.11.1 版本的 Apache Camel。

更新:根据克劳斯易卜生的说法,这可能是骆驼红隼组件的问题。我在 ASF Jira 上为 Camel 提交了一个问题:CAMEL-6632

4

1 回答 1

1

这是骆驼红隼中的一个错误,已记录 JIRA 票证以解决此问题:https ://issues.apache.org/jira/browse/CAMEL-6632

于 2013-08-14T10:59:36.763 回答