我有一个 Camel 进程(我从命令行运行),其路径与此类似:
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"文档,但是我找不到可以解释我所面临的行为的内容。
正如您从日志中看到的那样,我使用的是 Apache Camel 的 2.11.1 版本。
更新:根据 Claus Ibsen 的说法,这可能是 Camel 红隼组件的问题。我在 ASF Jira for Camel 上提交了一个问题:CAMEL-6632
最佳答案
这是 camel-kestrel 中的错误,已记录 JIRA 票证以修复此问题:https://issues.apache.org/jira/browse/CAMEL-6632
关于java - Camel 进程不会因为(不存在的)机上交换而关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18203999/