users@glassfish.java.net

Re: RE: Keeping a timer alive

From: <glassfish_at_javadesktop.org>
Date: Fri, 25 Jul 2008 14:05:24 PDT

One problem is that if you get an exception within Toplink, it completely grenades your transaction, and you're doomed forever.

The way I handled this was I had the Timer code call another Session Bean with "REQUIRES_NEW" for the transaction attribute, this separated the actual running code from the Timer code, which leverages the current transaction (far as I can tell). With the business logic in a completely different transaction, it can whine and complain and implode for whatever reasons it wants, while keeping the Timer transaction "clean". This is the easiest way to insulate a Timer process from the vagaries of what's running inside of it.

I also, as a rule, have timers reschedule themselves so that if the process for some unknown reason "takes too long", you don't have to worry about the same process running on top of itself.

YMMV. Do not use while bathing. No user serviceable parts inside.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=289470