Cron Jobs

You would create a NewsletterEmailCronJob item in your items.xml file having attributes for storing a personalizedMessage

<itemtype code=”NewsletterEmailCronJob” autocreate=”true” generate=”true” extends=”CronJob”
<description>Cronjob for sending Newsletter Email</description>
<attribute qualifier=”personalizedMessage” type=”java.lang.String”>
<persistence type=”property”/>

Now the above code would create the required Model class when you save it and run Ant Build script.

Jobs – 

Job is where your business logic goes and it uses the CronJob Model you created as part of CronJob above.

Here you would create a class say NewsletterEmailJob which would extend AbstractJobPerformable and would work on NewsletterEmailCronJobModel.

You would override the perform method to write the business logic in it.

Code Snippet:

public class NewsletterEmailJob extends AbstractJobPerformable<NewsletterEmailCronJobModel>

public PerformResult perform(final NewsletterEmailCronJobModel cronJob)

….. Logic for sending News letter Email with Personalized Message ….



Also, you would define a bean for the above class in your spring.xml file as follows:

<bean id=”newsletterEmailJob” class=””
parent=”abstractJobPerformable” >

Create the CronJob and the Trigger

To create the CronJob and the Trigger, you can either:

  • You can go in the hybris Admin Console to the Console tab select ImpEx Import and execute the following impex-script there by clicking on the Import Content button
    INSERT_UPDATE CronJob; code[unique=true];job(code);singleExecutable;sessionLanguage(isocode)
    INSERT_UPDATE Trigger;cronjob(code)[unique=true];cronExpression
    #% afterEach: impex.getLastImportedItem().setActivationTime(new Date());
    ; sendRankingCronJob; 0 0 0 * * ?
  • OR create the file resources/impex/essentialdataJobs.impex with the same content. Further changes are only taken into account after a server-restart and a system update (with only essential data checked). Changes made to resources after being loaded as classloader-resources are not visible.
%d bloggers like this: