为什么在 Spring Cloud Data Flow 中启动任务后没有销毁?

问题描述 投票:0回答:2

我创建了一些 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

并通过使用 JobExecutionListenerSupport 使用 afterJob 方法 任务(作业)的日志以:

结尾
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 作业有这些问题吗?

我的主要问题是哪一个负责完全停止 JVM(任务)? Spring Cloud Data Flow 部分或 Spring Batch 部分以及如何?

我认为当任务完成后,它应该被销毁(JVM被停止)并且并发任务执行的数量不能达到极限。

spring spring-batch spring-cloud-dataflow
2个回答
2
投票

我从github上得到了设置属性的解决方案

spring.cloud.task.closecontext_enabled = true
。但是我想深入了解没有 spring.cloud.task.closecontext_enabled 情况下上下文没有完全关闭的原因。将该属性设置为 true 后。我的 Spring Batch 项目日志显示警告:

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;  
}

0
投票

我也面临着类似的问题。 我在我的申请中包含了以下入门者
spring-boot-starter-webflux spring-boot-启动器-执行器 龙目岛 spring-cloud-starter-任务 spring-boot-starter-batch 弹簧启动启动器批处理 spring-cloud-starter-kubernetes-客户端配置 PostgreSQL spring-boot-配置-处理器 spring-boot-starter-测试 春云流 反应堆测试

© www.soinside.com 2019 - 2024. All rights reserved.