cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member623977
Active Participant
0 Kudos

Hi ,

Cron Job describes a single run of a Job default. It depends on the number of triggers you have added to trigger your cron job.There is always a Task item created for every Trigger and handled completely by the TaskEngine which is polling the Tasks. It takes care of trigger activation and performing cronjob this way.

I think you should use CronJobProgressTracker class as it saves data to the CronJobHistory item in every 5 seconds. And There are cron job events also that you can implement.

Please refer below links, might be helpful to you -

https://help.hybris.com/1808/hcd/b8004ccfcbc048faa9558ae40ea7b188.html

https://help.hybris.com/1808/hcd/2b87307fa7ee448886b78b62fe1bb9bc.html

Regards,

Prashant