Search code examples
javaspring-batchspring-cloud-dataflow

How to avoid relaunching task while it's status is still running on Spring Cloud Data Flow


I have deployed a Spring Batch project as a task on Spring Cloud Data Flow.

I have launched the task for the first time (It was going to run about 5 minutes which made the status of task is "running"). However, I have relaunched this task for the second time when it's status is running and it worked again.

1) How can I configure that the task could not be relaunched until it's completed status for the last time. 2) Besides, I found that when stopping the job, it will execute until it finishes the current step(My job has 2 steps and the second step was not executed ). However, are there any ways to shut down it (step 1) immediately when I stop the job?


Solution

  • How to avoid relaunching task while it's status is still running on Spring Cloud Data Flow

    Spring Cloud Task 2.0.0 added a feature that allows you to prevent tasks from running concurrently. See https://spring.io/blog/2018/05/07/spring-cloud-task-2-0-0-release-is-now-available#restricting-concurrent-task-execution

    You need to activate the spring.cloud.task.singleInstanceEnabled=true property.

    You can find more details in the Restricting Spring Cloud Task Instances section.