开发者

Multiple mail reminders at different times using quartz API

I am using Quartz scheduler for cron job of sending mails to users. I have one set of users for which I want to send the mails at first time (say 9o'clock in the morning开发者_如何学JAVA). I have another set of users for which I want to send the mails at another time (say 10o'clock in the morning). I have thirsd set of users for which I want to send the mails at third time (say 11o'clock in the morning).

Means, I have same job of sending mails but different set of users and triggered at different times.

Can anyone help me on this ?

Thanks


Code your job to look for the set of users in the merged JobDataMap (the one on the JobExecutionContext).

Define one instance of your job, but store it with three triggers set up to fire it(one for 9:00, one for 10:00, and one for 11:00). On each of the triggers' JobDataMap, store the identifier of the list of names to send emails to. When each given trigger fires, its JobDataMap values will be in the merged JobDataMap, and the job will know which set of users to send an email to.

If the sets of users are very large (say more than a few dozen names), I would recommend only putting an identifier to the set (which the job can use to retrieve the set from elsewhere) in the JobDataMap, rather than the set itself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜