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



summary of the day's transactions.... something

like



that.

Does Tomcat provide some sort of ActionEvent

which


you


can configure to be fired every x milliseconds?





---------------------------------------------------------------------

To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]




__________________________________ 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]





---------------------------------------------------------------------

To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]




__________________________________ 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]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to