我有一个Camel 2.25.0路由,监听一个聚集在密钥上的JMS队列。聚合配置为具有10分钟的完成超时,LevelDBAggregationRepository
和UseLatestAggregationStrategy
。
from("jms:inbound")
.log("Received views change stream")
.bean(viewService, "updateDependencies")
.aggregate()
.header("JMSXGroupID")
.aggregationStrategy(new UseLatestAggregationStrategy())
.completionTimeout(600000) // 10 minutes
.completeAllOnStop()
.aggregationRepository(new LevelDBAggregationRepository("aggregation-repository", "./aggregation-repository"))
.log("Process views change stream")
.to("jms:outbound");
有时会阻塞线程,并且不会占用队列。发生这种情况时,日志显示updateDependencies
调用与聚合开始之间有一个等待。 XXXX
是上一个聚合的结尾,而YYYY
是阻止的聚合。
APM duration: 1,073.2s
August 7th 2020, 11:39:20.327 onAggregation +++ end +++ with correlation key: XXXX
August 7th 2020, 11:39:20.327 Received views change stream
August 7th 2020, 11:39:20.341 1 documents touched based on update // log from updateDependencies
August 7th 2020, 11:57:13.555 onAggregation +++ start +++ with correlation key: YYYY
在AggregateProcessor
中,聚合之前有一个锁
lock.lock();
try {
aggregated = doAggregation(key, copy);
} finally {
lock.unlock();
}
我的猜测是等待时间是由于锁造成的,但这没有任何意义,因为我们可以看到先前的聚合(XXXX
)已经完成,因此应该释放锁。
我还检查了应用程序,其他线程仍在运行。