I am working on a task where I need to trigger a cronjob immediately after one cronjob is completed. Is there any way I can call the 2nd cronjob into 1st one, so that once the first one gets executed, the 2nd one should start automatically?
Asked
Active
Viewed 246 times
2 Answers
2
Yes, SAP Commerce Cloud offers this OOTB(Out Of The Box).
This can be achieved via composite cronjob:
INSERT_UPDATE CompositeCronJob; code[unique = true] ; job(code)[default = 'compositeJobPerformable']; sessionLanguage(isocode)[default = 'en']
; compositeJob ;
INSERT_UPDATE CompositeEntry; code[unique = true]; executableCronJob(code); compositeCronJob(code)[default = compositeJob];
; cronJob1Entry ; cronJob1 ;
; cronJob2Entry ; cronJob2 ;
# Adding trigger on the composite job . This will decide when the first cronjob from the sequence will start.
# After the first cronjob is finished the second will start
INSERT_UPDATE Trigger; cronjob(code)[unique = true]; cronExpression ;
; compositeJob ; 0 0/30 * ? * * * ;
You can find out more about Composite Jobs if you do a little digging. ex: https://answers.sap.com/questions/12768289/how-to-create-composite-cronjob.html

dj_frunza
- 1,553
- 3
- 17
- 28
0
Check CronJobService
get the cronJobModel :
cronJobService.getCronjob(code)
execute the cronJob :
cronjobService.performCronJob(cronJobModel)

Adiputera
- 171
- 1
- 2
- 13