I'm working on a project where the previous developers obviously wanted to try out every new technology (whether it was needed or not), and also wherever possible to write their own versions of modules where one would usually use an off-the-shelf one. To implement scheduled running of reports, the process looked like:
1. Use quartz (an easy-to-use java scheduling library) to schedule your reports, BUT not directly -- use it to run some custom code EVERY 30 SECONDS that runs a whole lot of expensive database calls and re-implements quartz's cron parsing functionality to figure out when to run the reports
2. When your scheduled time comes up, call a service that sends a JMS message to a queue that is always in the same JVM
3. When you duly receive this message, figure out some parameters to run the report with and send ANOTHER JMS message (in the same style as step 2)
4. When you receive THIS message, invoke your custom-built workflow engine to run a workflow that has a single step
5. This step will actually run the report (using jasper), but it might need to email the resulting file to some people, so we will use (you guessed it)
6. YET ANOTHER JMS message
7. Which, when recieved, emails the resulting file to the desired people
I removed all the JMS queues and the workflow, and changed it to use quartz directly. I removed huge swathes of code, a whole lot of load of the server, and made it run quicker.
And I didn't even mention the custome class loader it used so it could load the report definitions off the database every time it needed to run the report ... *shudder*.