延长 Spring Batch 中的执行时间限制
温馨提示:
本文最后更新于 2024年04月12日,已超过 48 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
我这里有一个大问题,Spring Batch + TaskExecutor 执行线程的时间不会超过 10 分钟,当然,如果有必要,我需要最终批处理作业需要 2 小时。
你只需这样做:java -jar receip-processor-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
正好在 10 分钟后: 2024-04-10T13:59:41.798-03:00 INFO 26072 --- [ main] oscsupport.DefaultLifecycleProcessor :无法在 600000ms 的超时时间关闭阶段为 2147483647 的 1 个 bean:[taskExecutor1 ]
600000ms相当于10分钟。
taskExecutor的配置非常标准:
@Bean
public TaskExecutor taskExecutor1() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setAwaitTerminationSeconds(10000);
taskExecutor.setMaxPoolSize(10);
taskExecutor.setQueueCapacity(25);
taskExecutor.setThreadNamePrefix("taskExecutor1-prueba-");
taskExecutor.initialize();
return taskExecutor;
}
但是
如何延长Bean的超时时间,例如延长至3小时?
我已经尝试过:taskExecutor.setAwaitTerminationSeconds(10000); taskExecutor.setKeepAliveSeconds(10800);即设置超时时间为3小时。
正文到此结束
- 本文标签: 家庭宠物
- 本文链接: https://www.coder6.net/article/2269
- 版权声明: 本文由蚂蚁原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
热门推荐
-
浏览(193) 评论(0)