ins*_*ect 8 java spring scheduled-tasks spring-annotations
我有一个类MessageProcessor被另一个类中的另一个方法调用(即调用者).
public class Caller {
@Scheduled(filxedDelay=10)
public void poll(){
//do stuff
messageProcessor.process(msg);
}
}
public class MessageProcessor{
@Async(value="abcExecutor")
public void process(String msg){
//do stuff here.
}
}
Run Code Online (Sandbox Code Playgroud)
Spring文件看起来像:
<task:executor id="abcExecutor" pool-size="9" rejection-policy-"CALLER_RUNS"/>
Run Code Online (Sandbox Code Playgroud)
我想添加另一个@Async执行程序:
@Async(value="defExecutor")
public void remove(String msg){
//do stuff here.
}
@Scheduled(filxedDelay=10)
public void kill(){
//do stuff
messageProcessor.remove(msg);
}
Run Code Online (Sandbox Code Playgroud)
通过在spring文件中添加另一个执行程序:
<task:executor id="defExecutor" pool-size="9" rejection-policy="CALLER_RUNS"/>
Run Code Online (Sandbox Code Playgroud)
但是如何在中添加多个执行程序 <task:annotation-driven executor="abcExecutor" scheduler="scheduler" mode="proxy" proxy-target-class="true"/>
如何使用注释运行这些多个执行程序?
PS:显然,我不希望这两种@Async方法都使用相同的池
| 归档时间: |
|
| 查看次数: |
9087 次 |
| 最近记录: |