Apache Camel split 与线程池并行运行,为什么?

Apache Camel split runs in parallell with ThreadPool, why?

我有一个 camelRoute,它应该在拆分中使用 threadPool 来执行并行工作。我的问题是我 总是以一个线程结束,因为拆分将 运行 一个线程和线程池指定数量的线程。 我希望线程池达到上限线程的数量。

谁能看出为什么会这样? Route 和 camel-context 下面...(代码中的其他值,如 from 和 id 等,但无法在此处显示...)

from(FROM_ENDPOINT)
    .routeId(ID)
    .split(body(), new GroupedExchangeAggregationStrategy())
    .executorServiceRef("ThreadPool")
    .bean(bean, "beanMethod")
    .end()
    .bean(bean)
    .multicast()
    .to(TO_ENDPOINT);

线程池在我的骆驼中是这样配置的-context.xml:

<camel:camelContext id="application-context" useMDCLogging="true" xmlns="http://camel.apache.org/schema/spring">
    <propertyPlaceholder id="properties" location="ref:props"/>
    <routeBuilder ref="refToRoute"/>
    <threadPoolProfile id="ThreadPool" maxPoolSize="2"
                       maxQueueSize="-1" poolSize="2"/>
</camel:camelContext>

拆分器需要一个后台线程来协调并行工作。所以你有来自线程池的线程 + 一个名为 Splitter-AggregateTask.

的额外线程

因此,如果您希望总数最多为 10,则将线程池大小设置为 9,这样您也有空间容纳 1 个后台线程。