You're right, no-one said I can't. :) I was hoping someone who has actually used it could give some feedback about it.
The (obvious) reason why the scheduled task also cannot be active if the web-app is not active, is that the scheduled task requires users to use web-app. Eg, Friday at 15:00 you get an e-mail to fill in your time-sheet if it has not been done. If the web-app is not active, then there is no point in sending the mail. If you do, then the sysop is going to get 1000 mails/phone call from users saying "I need to fill out my timesheet, but the app is down!". Purely a user requirement. I think you can see the logic behind this. When the web-app comes alive again, the first thing that will be done, is to send the warnings and people can get back to filling out timesheets. It won't be a heavy burderned task... thread.sleep for 1 hour eg and then do one date/time check.... I think that wouldn't be too heavy on performance. Thanks for the feedback, though. --- John Turner <[EMAIL PROTECTED]> wrote: > > Nobody, from what I can tell, is saying "can't". > You did ask, though. > > If you're willing to be diligent about coding your > threads, go for it. > I think the point of previous posts was that in many > cases, there is no > need for such a thing as your asking. There are > always exceptions to > the rule, though. > > For example: the question "is it past midnight" > would never be asked if > you were to use the operating system, since with > something like cron > (built in scheduler), the operating already knows if > its past midnight. > Thus, the question becomes not a question but a > command: "its past > midnight, go find all of the people who have a > status of X and remind > them to change their status to Y." The effort, > then, is spent on the > business logic, not on trying to figure out if its > time to spend time on > the business logic. > > The alternative is to spend resources constantly > wondering if a specific > time is reached. For one or two events, no problem. > Start getting > busy, start having 10 or 20 events, and it becomes a > problem, not just > from a resource standpoint, but from an > administration and > synchronization standpoint. > > John > > Riaan Oberholzer wrote: > > > Perhaps I should give a better explanation of how > the > > application works: > > > > I deliver a .war file. I do have access to an > > underlying database. The scheduled tasks perform > more > > on a "is time reached" than "has time elapsed" > > principle... eg, it triggers when "is it past > > midnight?" instead of "has 24 hours elapsed?". > > > > I cannot see why creating a daemon thread cannot > cater > > for this. You just start the thread in the init > method > > of the InitServlet (or any servlet you create with > > start-when-app-starts). > > > > What am I missing here? Why can't I use this > method? > > If Tomcat crashes and the app gets restarted, my > > thread will be restarted as well, so no problem > there. > > The thread should also only be running while the > > web-app is (LONG story why that is so, so I won't > give > > details... in short, if the web-app is down, it is > > seen as critical and all else must be halted). > > > > > > --- John Turner <[EMAIL PROTECTED]> > wrote: > > > >>cron = scheduler > >> > >>wget = command line HTTP/HTTPS client > >> > >>The requirement for delivering everything in a WAR > >>file is all nice and > >>dandy, but if you think about it, the requirement > >>automatically breaks > >>the other requirement: scheduling. > >> > >>If you cannot have a log file, and you cannot > access > >>a database, how > >>will you ever be able to determine elapsed time, > >>which is the primary > >>requirement for a scheduler? How can you > determine > >>status like when was > >>the last time it was run, etc? How can you reset > >>your clock if the app > >>is shutdown? How do you know the app has been > >>shutdown due to an > >>external event? > >> > >>John > >> > >>Riaan Oberholzer wrote: > >> > >> > >>>... nice suggestion, but I am delivering an > >>>application as a .war file to a 3rd party and > they > >>>just want the .war (+ context.xml) with > everything > >> > >>in > >> > >>>it.... hence, no other applications checking the > >> > >>logs > >> > >>>or database. All functionality must come from the > >> > >>.war > >> > >>>running in Tomcat. It is very important: all > >>>functionality must be encapsulated in the .war > >> > >>file. > >> > >>>(I have no idea what cron +wegt is???) > >>> > >>>I guess a daemon thread will be my choice > solution > >> > >>for > >> > >>>now... what the thread does, is check a database > >> > >>daily > >> > >>>for a certain false condition and send an e-mail > >> > >>to > >> > >>>all users in question warning them about the > >> > >>current > >> > >>>status. E.g. if you have to submit your timesheet > >> > >>by > >> > >>>Friday 17:00, then you'll get a warning on Friday > >> > >>at > >> > >>>12:00 if it is not done yet.... something like > >> > >>that. > >> > >>> > >>> > >>> > >>>--- Tim Funk <[EMAIL PROTECTED]> wrote: > >>> > >>> > >>>>Tomcat doesn't provide this but other simple > >>>>solutions exist such as exposing > >>>>a URL and using cron + wget. (Some may also say > >>>>kludge too) > >>>> > >>>>As for aggregating statistics - I would > recommend > >>>>using a log file to record > >>>>the essential measurements then running your > stats > >>>>program on the logs. This > >>>>way - tomcat can crash (or other strange > >> > >>occurences > >> > >>>>may occur) and you lose > >>>>no data. If the data is already logged, then the > >>>>first solution (cron + wget) > >>>>will work well too. > >>>> > >>>>-Tim > >>>> > >>>>Riaan Oberholzer wrote: > >>>> > >>>> > >>>>>Well, that was part of my question.... if I > >>>>>cannot/don't implement daemon threads to do > e.g. > >>>>>automatic daily tasks, what else? E.g, at the > end > >>>> > >>>>of > >>>> > >>>> > >>>>>the day send an e-mail to a (real life) manager > >>>> > >>>>with a > >>>> > >>>> > === message truncated === __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]