cancel
Showing results for 
Search instead for 
Did you mean: 

Change CronJob Notification Email ONLY on failure

Mpcasas
Explorer
0 Kudos
402

We need send email only when cron job fail. How can we extend the default emails of cron jobs?

View Entire Topic
fionnziegler2
Explorer
Mpcasas
Explorer
0 Kudos

Hi Fionn,

We've seen it but the answer is not complete. Where is the "sendEmail(CronJobResult cronJobResult)" method?

Thanks!

fionnziegler2
Explorer
0 Kudos

2 options:

1) put it at the end in your cronjob perform method

2) create a custom CronJobNotificationEmailHandler which can be configured in the backoffice

fionnziegler2
Explorer
0 Kudos

1. overwrite de.hybris.platform.cronjob.jalo.CronJob.sendEmail

there you can only send the email if it was a failure:

if (!getResult().getCode().equals(de.hybris.platform.cronjob.constants.GeneratedCronJobConstants.Enumerations.CronJobResult.SUCCESS)) {
//do your magic to send an email