我正在将ThreadPoolTaskExecutor自动装入我的spring批处理编写器类中。在生成线程之前,我必须检查执行程序是否处于活动状态。如果执行程序关闭,则需要重新实例化。可以在春天做吗?
public class FooWriter implements ItemWriter<Long> {
@Autowired
@Qualifier("taskExecutor")
private ThreadPoolTaskExecutor executor;
@Autowired
private FooRunnable fooRunnable;
@Override
public void write(List<? extends Long> items) throws Exception {
executor.execute(fooRunnable);
executor.shutdown();
}
}