Spring integration 是使用ThreadPoolExecutor应用程序范围请求的Executor通道的池大小

Spring integration 是使用ThreadPoolExecutor应用程序范围请求的Executor通道的池大小,spring-integration,Spring Integration,目前,我使用带有的作为拆分器的输出通道,该拆分器将一条消息拆分为两条不同的消息以并行运行 我已经设置了输出通道,如下所示: 我无法完全理解当同时发送多个请求时,池大小是如何工作的。如果我通过这个流向我的应用程序发送一个请求,它将在“splitter_output”通道中产生两条不同的消息。如果我向我的应用程序发送3个请求,则会在“splitter_output”通道中产生6条不同的消息,因为每个请求都流入一个拆分器,该拆分器将消息拆分为两条单独的消息 此池大小是否为每个请求设置,其中每个请求

目前,我使用带有的作为拆分器的输出通道,该拆分器将一条消息拆分为两条不同的消息以并行运行

我已经设置了输出通道,如下所示:


我无法完全理解当同时发送多个请求时,池大小是如何工作的。如果我通过这个流向我的应用程序发送一个请求,它将在“splitter_output”通道中产生两条不同的消息。如果我向我的应用程序发送3个请求,则会在“splitter_output”通道中产生6条不同的消息,因为每个请求都流入一个拆分器,该拆分器将消息拆分为两条单独的消息

此池大小是否为每个请求设置,其中每个请求将产生两个执行器线程以继续向下流


或者是在应用程序范围内,前两个请求将导致(4)个线程被创建并在流中运行,然后一旦其中一个请求完成,第三个请求将创建(2)个线程并继续在流中运行

首先,它不是Spring集成特性,而是Spring框架的核心特性

这是一份关于此事的文件:

关于
池大小
,请参见其说明:

The size of the executor's thread pool as either a single value or a range
(e.g. 5-10). If no bounded queue-capacity value is provided, then a max value
has no effect unless the range is specified as 0-n. In that case, the core pool
will have a size of n, but the 'allowCoreThreadTimeout' flag will be set to true.
If a queue-capacity is provided, then the lower bound of a range will map to the
core size and the upper bound will map to the max size. If this attribute is not
provided, the default core size will be 1, and the default max size will be
Integer.MAX_VALUE (i.e. unbounded).
ThreadPoolTaskExecutor
支持。以下是它的JavaDocs:

 * JavaBean that allows for configuring a {@link java.util.concurrent.ThreadPoolExecutor}
 * in bean style (through its "corePoolSize", "maxPoolSize", "keepAliveSeconds", "queueCapacity"
 * properties) and exposing it as a Spring {@link org.springframework.core.task.TaskExecutor}.
 * This class is also well suited for management and monitoring (e.g. through JMX),
 * providing several useful attributes: "corePoolSize", "maxPoolSize", "keepAliveSeconds"
 * (all supporting updates at runtime); "poolSize", "activeCount" (for introspection only).

我不确定是什么让你认为线程行为是关于“每个请求”。事实上,它是一个具有
4
threads配置的全局单例bean,每个想要在此执行器上执行任务的人都必须与所有其他人共享线程。因此,与请求量无关,这里只有4个线程可以工作。其他一切都在内部队列中等待。

我想这是每个请求,因为我一次只发送一个请求,当我发送请求时,它会在日志中显示[executor-1]和[executor-2]作为线程上下文,然后当我发出第二个请求时,(在第一个请求完成后),它会显示[executor-3]和[executor-2][executor-4]用于线程上下文。我想我只是误解了我是如何解释线程是如何创建的。这是一个很棒的解释,回答了我的问题。好吧,它会将线程生成到池中,并在可用时重用它们。我想这两个线程首先会用到一些“正在使用”中同时,其他人已经准备好立即处理任务。如果这能解决你的问题,请考虑: