Skip to Content
0
Jan 10, 2019 at 04:17 PM

Waiting untill all tasks are done before checking status of the Cronjob that created them

340 Views

Dear experts, et. al.,

We are using the cronJobService to perform a cronjob (cronJobService.performCronJob(cronJob)) in combination with a cluster environment. At some point, the cronJobService will schedule tasks using the taskService, which internally spawns a number of threads (e.g. 10).

When those threads have finished executing we need to check the status of the Cronjob and we are doing it in the following way:

     if (cronJobService.isFinished(cronJob) && cronJobService.isSuccessful(cronJob))
     {
         ...
     }


However, it is possible that the scheduler would execute the portion of the code that checks if the cronjob has finished before all the generated tasks have finished execution. We basically need to find a way to wait until those tasks are done and then check the status of the Cronjob.

Any help would be greatly appreciated!

Regards,

L