spring - 为什么在 Spring Cloud Data Flow 中启动后没有销毁任务?
问题描述
我创建了一些 Spring Batch 项目并使用 Spring Cloud Data Flow (SCDF) 部署这些作业。
在 SCDF 中启动任务(作业)后,它会创建 JVM 来执行任务(作业)。
但是,当任务完成时,那个 JVM 并没有结束。它仍然存在。
当我启动我的工作 20 次时,它宣布
Cannot launch task A. The maximum concurrent task executions is at its limit [20]
还有一些关于我的工作的信息,工作的第一个日志以:
HikariPool-1 - Shutting down...
但是在我为 Spring Batch 项目使用了以下属性之后:
spring.cloud.task.singleInstanceEnabled=true
并使用 afterJob 方法通过使用 JobExecutionListenerSupport 任务(job)的日志以:
o.s.b.c.l.support.SimpleJobLauncher : Job: [SimpleJob: [name=remindJob]] completed with the following parameters: [{run.id=3}] and the following status: [COMPLETED] in 7s636ms
o.s.integration.leader.DefaultCandidate : DefaultCandidate{role=EngineProcess, id=126} leadership has been revoked: LockContext{role=Process, id=126, isLeader=false}
我的 Spring Batch Job 有这些问题吗?
我的主要问题是哪个负责完全停止 JVM(任务)?Spring Cloud Data Flow 部分或 Spring Batch 部分以及如何?
我认为当任务完成时,它应该被销毁(JVM停止)并且并发任务执行的数量不能达到限制。
解决方案
我从 github 获得了设置属性的解决方案spring.cloud.task.closecontext_enabled = true
。但是我想深入了解没有spring.cloud.task.closecontext_enabled上下文没有完全关闭的原因。将该属性设置为 true 后。我的 Spring Batch 项目的日志显示了 WARN:
main] o.s.b.f.support.DisposableBeanAdapter : Destroy method 'close' on bean with name 'getStudent' threw an exception: org.springframework.batch.item.ItemStreamException: Error while closing item reader
还有 ItemReader 代码:
@Bean
public JdbcCursorItemReader<Student> getStudent() {
JdbcCursorItemReader <Student> reader = new JdbcCursorItemReader<>();
reader.setDataSource(dataSource);
reader.setSql(QueryConstants.getStudent);
reader.setRowMapper(new BeanPropertyRowMapper<>(Student.class));
return reader;
}
推荐阅读
- django - 我如何覆盖用户保存 Django allauth.socialaccounts
- c++ - opreport 似乎报告了错误的模板实例化
- java - Android 尝试使用资源未找到方法 close()
- tomcat - Lucee IIS10 - Tomcat 8.5 BonCodeAJP 连接器 - 通用连接器通信错误
- php - 为什么我在循环中的帖子占据了整个屏幕的宽度?
- java - 迭代器如何在 LinkedList 上工作?
- reactjs - 试图通过数组做出反应
- html - 添加边距时 div 超出父 div
- azure-data-factory - ADF CDM 源转换未读取数据
- python - 如何解决 ImportError: cannot import name 'Tweet' from 'GetOldTweets3.models.Tweet'