I am in the analysis phase of a project with the following specs (in a nutshell):
Allow users to save their searches for the journals in our database and receive via email periodic reports (they may choose a frequency of daily, weekly, monthly) listing new journals added to our database matching their search.
It seems obvious that I want to create a table containing fields for the actual search (query text), the user id, email address to send the report to, the frequency of the report, the date report was last run, and the date the report expires. (Those are the essential fields. I may discover additional fields as I delve further into this project.)
The application will run a nightly cron job to generate the reports. In my idea for its implementation, it would iterate over the search table described above, creating and emailing each report. Actually, I will probably query the search table for reports that are due to run that night and iterate over that result set.
My question here is about the use of a servlet for this job. Couldn't I create one object to iterate through the "reports due" result set and submit the process of creating and emailing the reports to a servlet? I'm thinking that such an implementation would allow for a multi-threaded solution. Obviously, iterating over a result set is sequential, but if I call a servlet to do the actual processing, don't I have multi-threading in that the app could call the servlet again before finishing each request? The iterating object would not have to wait for the servlet to finish generating one report before going to the next record in the result set and calling the servlet again, right?