Spring integration 使用Dispatcher的Spring集成异步处理

Spring integration 使用Dispatcher的Spring集成异步处理,spring-integration,Spring Integration,我从不同线程中的多个源接收数据。计划将数据传递到单个通道,然后一个单独的线程将处理来自该通道的数据。我的背景如下 <task:executor id="singleThreadedExecutor" pool-size="1" /> <int:channel id="entryChannel"> <int:dispatcher task-executor="singleThreadedExecutor"/> </int:channel>

我从不同线程中的多个源接收数据。计划将数据传递到单个通道,然后一个单独的线程将处理来自该通道的数据。我的背景如下

<task:executor id="singleThreadedExecutor" pool-size="1" />
<int:channel id="entryChannel">
    <int:dispatcher task-executor="singleThreadedExecutor"/>
</int:channel>

<int:header-enricher input-channel="entryChannel" output-channel="processDataChannel">
    <int:error-channel ref="exceptionHandlerChannel" overwrite="true" />
    <int:header name="systemtime" expression="T(java.lang.System).currentTimeMillis()" />
    <int:header name="nanotime" expression="T(java.lang.System).nanoTime()" />  
</int:header-enricher>

我想在数据到达后立即处理它。我担心在单独的线程中,数据到达的速度比数据处理时间快得多。 根据文档,在entryChannel上调用Send应该立即返回。 dispatcher是否具有内部排队机制,以确保将数据移交给通道?我们如何确保数据一到就移交?
有兴趣了解在SI中需要在单独线程中处理数据时的最佳实践吗?

任务执行器本身将任务(调用订阅的端点)保存在队列中,因此,是的,调用者会立即退出(只要队列中有空间,这在您的配置中始终是正确的)。

首先,您的问题是:

<task:executor id="singleThreadedExecutor" pool-size="1" />

独立于发件人,只有一个
线程
能够从
入口通道
获取消息。它只有在空闲并且准备好执行您的请求时才能这样做。但在您的情况下,它忙于处理第一条消息,然后是第二条消息,依此类推。一个接一个,一次只能处理一条消息,因为它是一个线程

您只需要增加池大小(例如10),就可以将来自该通道的消息分发给多个并行线程

关于第二个问题: