Java 具有注释驱动的spring任务的多个spring任务执行器

Java 具有注释驱动的spring任务的多个spring任务执行器,java,spring,scheduled-tasks,spring-annotations,Java,Spring,Scheduled Tasks,Spring Annotations,我有一个类MessageProcessor被另一个类(即调用者)中的另一个方法调用 Spring文件看起来像: <task:executor id="abcExecutor" pool-size="9" rejection-policy-"CALLER_RUNS"/> 通过在spring文件中添加另一个执行器: <task:executor id="defExecutor" pool-size="9" rejection-policy="CALLER_RUNS"/>

我有一个类
MessageProcessor
被另一个类(即调用者)中的另一个方法调用

Spring文件看起来像:

<task:executor id="abcExecutor" pool-size="9" rejection-policy-"CALLER_RUNS"/>
通过在spring文件中添加另一个执行器:

<task:executor id="defExecutor" pool-size="9" rejection-policy="CALLER_RUNS"/>

但是如何在

如何使这些多个执行器与注释一起运行

PS:显然,我不想让同一个池同时用于两个
@Async
方法

@Async(“defeexecutor”)
足以指定由第二个执行器处理的方法。xml声明仅指定默认的执行器,在
@Async
中未指定任何值时将使用该执行器


请参见中的:

那么,它是正确的XML吗

<task:executor id="abcExecutor" pool-size="9" rejection-policy-"CALLER_RUNS"/>
<task:executor id="defExecutor" pool-size="9" rejection-policy="CALLER_RUNS"/>
<task:annotation-driven executor="abcExecutor" scheduler="scheduler" mode="proxy" proxy-target-class="true"/>


它应该通过指定@Async的
值来工作。无需在xml中指定它。您试过并查看使用了哪个执行器了吗?我现在无法尝试,但它会由xml中提到的线程池(即9个线程)处理吗?两个线程池都是9个线程,所以我不知道您指的是哪一个:),但它将由您指定的执行器或默认值处理
@Scheduled
注释怎么办?有没有办法指定它的执行者?你能再解释一下吗?
<task:executor id="defExecutor" pool-size="9" rejection-policy="CALLER_RUNS"/>
<task:executor id="abcExecutor" pool-size="9" rejection-policy-"CALLER_RUNS"/>
<task:executor id="defExecutor" pool-size="9" rejection-policy="CALLER_RUNS"/>
<task:annotation-driven executor="abcExecutor" scheduler="scheduler" mode="proxy" proxy-target-class="true"/>