I am using spring cloud data flow (1.3.0.RELEASE). I would like to detect a running task in order to prevent multiple instances of the same task being started.
I was looking at the task execution status features, specifically "End Time" but i noticed that sometimes task execution status can have "Start Time" set along with "Exit Code" set to 0 and "End Time" not set. Because of that, "End Time" does not look like a viable deciding factor.
What would be the best way to achieve that?
Thanks.
At the SCDF level, we don't (yet) have the native ability to control it as part of the orchestration layer. A few options are possible, though.
1) You could have the Task applications emit its lifecycle events via task-events
destination (queue or topic); it could be the standard types or custom events. A stream could then be used as a decision point to trigger the subsequent launches.
2) In the recent 2.0 M3 release of Spring Cloud Task, we can restrict the launch of multiple Task instances of the same type. This could effectively be controlled by the spring.cloud.task.singleInstanceEnabled=true
for each Task launches. With this flag set, while launching the Task instances, the lock-check would automatically be applied. Thus the duplicate or unintended launches can be prevented.
3) If you cannot switch to 2.0 M3, you could, in theory, replicate #2 solution from above on your 1.x based Task applications.