Use composite CronJob in Hybris
1. Overview
In Hybris, a composite cronJob is a composition of multiple cronJobs used when we need to run a bundle of cronJobs successively. It is often referred as an ordered all or nothing execution, e.g. MediaImportComposite composed of MediaImportCronJob and MediaConversionCronJob.
This is an overview of how composite cronJob work.
In this article, I will show you how to create a composite cronJob.
2. Implementation
Let’s assume that we have two cronJobs (totoCronJob and fooCronJob) that we want to run in order, refer to this article for more details on how to create a cronJob.
1. Create two instances of the CompositeEntryModel
:
INSERT_UPDATE CompositeEntry ;code[unique=true] ;executableCronJob(code)
;totoCronJobEntry ;totoCronJob
;fooCronJobEntry ;fooCronJob
2. Create an instance of the CompositeCronJobModel
and attach the composite entries to it.
INSERT_UPDATE CompositeCronJob ;code[unique=true] ;job(code) ;compositeEntries(code) ;sessionUser(uid)[default=admin] ;sessionLanguage(isocode)[default=en]
;helloCompositeCronJob;compositeJobPerformable;totoCronJobEntry, fooCronJobEntry
3. Run your composite cronJob from HMc.
Software Craftsmanship, Stackextend author and Full Stack developer with 6+ years of experience in Java/Kotlin, Java EE, Angular and Hybris…
I’m Passionate about Microservice architectures, Hexagonal architecture, Event Driven architecture, Event Sourcing and Domain Driven design (DDD)…
Huge fan of Clean Code school, SOLID, GRASP principles, Design Patterns, TDD and BDD.
Nice Article (y), What happens when a composite entry Crashes (continue the the execution of other entries or abort)? and in this case what is the status of the Composite cronjob ?
Hi, the composite cronJob is an all or nothing execution, which means if a composite entry failed, it will not execute the next one and the composite cronJob will passe to ERROR.
Hi Mouad EL Fakir,
I have created Composite cronjob with 3 entries. Composite cronjob is not failing even first entry getting failed. can you please help me.