I am looking to use quartz to schedule emails, but I'm not sure which approach to take:
I need to pass the message/recipient etc either way, and I'm not sure whether creating heaps of jobs will start adding considerable memory overheads, as there will quite possibly be thousands of emails scheduled.
Update: These emails will be scheduled by users, not by me - so I will be adding these programmatically at runtime, they aren't scheduled to go out at any particular time.
Quartz is intended to handle tens of thousands of triggers. The main limit to scalability here is the space available in your JobStore. A JDBCJobStore backed with a reasonable database should be able to handle hundreds of thousands of triggers.
If a single job can be parameterized through the trigger's job data map, create a single job and one trigger for each email. Quartz polls the job store periodically to look for triggers that are ready to fire. Quartz is designed to safely handle arbitrarily large result sets from this query.
What matters—and this really has nothing to do Quartz itself—is that you have the necessary bandwidth to execute peak loads. If users tend to schedule mails in clumps, you need to make sure that you have the computing resources to get the emails out. This would include network bandwidth, processing, and enough worker threads configured to utilize the available resources.
Note that you can configure what Quartz should do with a trigger if it does get too far behind in executing jobs. You can keep trying, skip the trigger, etc.
Are the triggers to be based on a time schedule? You can use a CronTrigger to set up a more complex time based schedule rather than individual triggers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With