Question

I'm about to create a small application which will be responsible for sending out various reports to various users at various intevals. We might be talking about 50 or 100 different reports going to different people. Some reports needs to be generated every day, some every week, and some every month.

I've been using the Quartz library earlier to run tasks at regular intervals. However, in order to keep things simple I like the thought of having a single Quartz thread taking care of all reports. That is, the thread should loop through all reports, say every 15 minutes, and determine wether it is time for one or more to be generated and sent. It does not matter if a report is generated at 12:00 or 12:15.

I'm thinking about wether it would be possible, somehow, for each report to set up specific times such as "mon@12:00,wed@12:00" or "fri@09:30". Then, based on that, the thread would determine if it was time to send a report or not.

My question is; has anyone else done something like this and does any libraries exist which can make it easy to implement this task?

Was it helpful?

Solution

why not simply register a separate quartz task instance for each report and let Quartz handle all the scheduling for you? That is after all the point behind it.

OTHER TIPS

you can create just single thread and it would ping a "job schedule data structure" at some time interval to see if it needs to run a report. If yes, it would run the report, otherwise, it would go for a short nap and ping again after specified sleep time.

It will cause problem if one job takes too much time to complete and you start accumulating jobs.

The job schedule data structure would keep its record sorted by time stamp.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top