暂停 Spring Cloud Data Flow 中的定时作业执行,直到前一个作业执行完成。

huangapple go评论73阅读模式
英文:

Hold the Scheduled Job Execution in SCDF until the previous job execution completes

问题

我在Openshift环境中运行SCDF。我正在安排一个Spring批处理作业,使其每5分钟运行一次。有时作业的运行时间可能超过5分钟。在这种情况下,是否可以暂停下一个预定的作业执行,直到前一个作业完成执行?

我们不想更改作业执行的频率,也不想更改时间间隔。

更新1:
最近我发现在Kubernetes cronjob中,我们可以添加concurrencyPolicy=forbid,以阻止在前一个作业仍在运行时发生下一个作业执行。

我正在寻找在SCDF中的等效配置。

谢谢。

英文:

I'm running SCDF in Openshift environment. I'm scheduling a Spring batch job to run once in every 5 minutes. Sometimes the job may run for more than 5 minutes. In that scenario, is it possible to hold the next scheduled job execution until the previous one completes its execution?

We don't want to change frequency of job execution also the interval.

Update 1:
Recently I found that with Kubernetes cronjob we can add concurrencyPolicy=forbid to stop the next job executions from happening if the previous one is still running.

I'm looking for equivalent configuration in SCDF.

Thanks.

答案1

得分: 1

请查看属性spring.cloud.task.single-instance-enabled。Documentation - Spring-cloud-task#features-single-instance-enabled
这可以防止两个具有相同名称的任务同时运行。
我在SCDF(2.6.1)上进行了检查,当运行两个相同的任务时,会出现以下错误:

Caused by: org.springframework.cloud.task.listener.TaskExecutionException: Task with name "timestamp-task" is already running.
	at org.springframework.cloud.task.configuration.SingleInstanceTaskListener.lockTask(SingleInstanceTaskListener.java:121) ~[spring-cloud-task-core-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
	... 31 common frames omitted
英文:

Have a look at property spring.cloud.task.single-instance-enabled. Документация - Spring-cloud-task#features-single-instance-enabled
This prevents two tasks with the same name from running.
I checked on SCDF (2.6.1) and when running two identical tasks got the error:

Caused by: org.springframework.cloud.task.listener.TaskExecutionException: Task with name "timestamp-task" is already running.
	at org.springframework.cloud.task.configuration.SingleInstanceTaskListener.lockTask(SingleInstanceTaskListener.java:121) ~[spring-cloud-task-core-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
	... 31 common frames omitted

huangapple
  • 本文由 发表于 2020年9月18日 14:31:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/63950424.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定