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”>
Now the above code would create the required Model class when you save it and run Ant Build script.
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.
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=”com.email.NewsletterEmailJob”
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=
#% afterEach: impex.getLastImportedItem().setActivationTime(
* * ?
- 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.