我不熟悉所有Spring Framework,我试图在下面的代码中将* .xml转换为Java Config。
我不确定应该如何创建执行者并设置rejection-policy="ABORT"
。
XAML文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<context:annotation-config />
<task:annotation-driven executor="processorExecutor" />
<task:executor
id="listenerExecutor"
pool-size="3-15"
queue-capacity="5000"
rejection-policy="ABORT" />
<task:executor
id="processorExecutor"
pool-size="3-15"
queue-capacity="5001"
rejection-policy="ABORT" />
<bean id='applicationEventMulticaster'
class='org.springframework.context.event.SimpleApplicationEventMulticaster'>
<property name='taskExecutor' ref='listenerExecutor' />
</bean>
<bean id="config"class="com.ebay.catalogs.pm.common.config.ApplicationConfigPropertiesFactorBean" />
</beans>
Java配置文件:
@Configuration
public class ApplicationConfig {
@Bean(name = "listenerExecutor")
public Executor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(3);
taskExecutor.setMaxPoolSize(15);
taskExecutor.setQueueCapacity(5000);
taskExecutor.setr
return taskExecutor;
}
@Bean(name = "processorExecutor")
public Executor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(3);
taskExecutor.setMaxPoolSize(15);
taskExecutor.setQueueCapacity(5001);
taskExecutor.setr
return taskExecutor;
}
}
答案 0 :(得分:1)
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());