I did my research but couldn't find the authentic answer. Any inputs from hybris experts highly appreciated
Asked
Active
Viewed 1.9k times
8
-
Check this link : https://www.stackextend.com/hybris/everything-about-cronjobs-in-hybris-part-1/ – Mouad EL Fakir Dec 28 '17 at 17:23
2 Answers
15
- Cronjob: The job to be performed. For this Create an item type extending from CronJob.
- Job: Where the actual cronjob logic will be written. For this Create a class extending from AbstractJobPerformable<...abovegeneratedModel> and override the perform() method. Here perform method will contain actual job logic.
- Define the above Job class as a bean in xxxcore-spring.xml.
- Go to hmc-->System-->Right click on Cronjobs and Create your new cronjob.
- Trigger: Holds cron expression when to fire cronjob. Add the trigger conditions through TimeSchedule tab.
- Click StartCronJob Now to schedule the cronjob.
You can also use impex script to create trigger as thijsraets said.
INSERT_UPDATE Trigger;cronJob(code)[unique=true];cronExpression
;myCronJob;30 23 14 2 5 ? 2015

Manohar Ch
- 453
- 1
- 3
- 22
-
MANY THANKS MANOHAR. What are the options for creating Trigger, other than Impex – prashant kumar May 13 '15 at 16:28
-
hmc-->system-->right click on cronjobs-->select the cronjob you wish to create-->select TimeSchedule tab... there you will find the trigger section --> right click in that section-->create trigger. – Manohar Ch May 14 '15 at 13:02
-
Many Thanks Manohar, Is Cron Job Linked to Java Thread ? What happens in a shutdown .... if it does not have an active Trigger – prashant kumar May 16 '15 at 13:01
-
What is the use of a cronjob without scheduling it. Trigger contains the scheduling criteria(like at what time to execute). – Manohar Ch May 16 '15 at 13:11
-
I think, on demand basis we can execute them as and when its needed when there is no trigger. So you can have a cronjob without any trigger. Hope this helps. – Thayz Jun 14 '17 at 07:21
7
You probably want this cronJob to perform a custom action, for this you need to link up the cronJob with an actual action/task: the job itself. Create a bean that extends AbstractJobPerformable
and implements the "perform" method. Now in the hMC you can create your Cron Job (System->CronJobs), under Job
point to the bean you have created.
If you would like to do this from code you can use impex, for instance:
INSERT_UPDATE CronJob;code[unique=true];job(code);sessionLanguage(isocode);sessionCurrency(isocode)
;myCronJob;myJobBean;en;EUR
INSERT_UPDATE Trigger;cronJob(code)[unique=true];cronExpression
;myCronJob;30 23 14 2 5 ? 2015
Assign to a String and import this impex (or just execute in hac):
final CSVReader importReader = new CSVReader(impEx);
final Importer importer = new Importer(importReader);
importer.getReader().setDumpingAllowed(true);
try
{
importer.importAll();
}
catch (final ImpExException e)
{
e.printStackTrace();
}
importReader.closeQuietly();
importer.close();
(If you are using 5.5.1: the triggers do not work properly if you indicate multiple execution times. No problem if you only specify a single execution time , we hope SAP will solve this)

thijsraets
- 573
- 1
- 5
- 13
-
-
just wondering why did you use IMPEX for adding Business Logic. What are the other options .... Bean shell, Interceptor, Java etc are there I believe – prashant kumar May 04 '15 at 09:31
-
just wondering why did you use IMPEX for adding Business Logic. What are the other options .... Bean shell, Interceptor, Java etc are there I believe – prashant kumar May 04 '15 at 09:32
-
You can also use CronJobModel (and set triggers), just thought impex looked transparent – thijsraets May 04 '15 at 11:52
-
well i am certainly not an expert on impex. I am trying to expand my conceptual understanding, but struggling to get the big picture ... where is Impex is used – prashant kumar May 05 '15 at 02:31