users@glassfish.java.net

RE: Keeping a timer alive

From: Manfred Riem <mriem_at_manorrock.org>
Date: Fri, 25 Jul 2008 13:00:33 -0600

Hi Marina,

Dru is talking about the code that is executed when the timer triggers ;)

Manfred

-----Original Message-----
From: Marina.Vatkina_at_Sun.COM [mailto:Marina.Vatkina_at_Sun.COM]
Sent: Friday, July 25, 2008 11:54 AM
To: users_at_glassfish.dev.java.net
Subject: Re: Keeping a timer alive

Timer in V2 is implemented using CMP, so there should be no TopLink code
involved.

thanks,
-marina

Dru Devore wrote:
> The exception thrown by toplink is picked up by the server before it
> gets to my code so I don't have the choice of catching the exception. So
> I have to configure the time in the server. Now if I have the server in
> a cluster how will this work? Will there be one executing at any one
> time managed by the container or one for each server in the cluster. If
> it is one running then which servers configuration is taken if there are
> differeneces. It would be nice if it was configurable in the web.xml, I
> looked and didn't see it.
>
> So many questions.
>
> -------- Original Message --------
> Subject: RE: Keeping a timer alive
> From: "Dru Devore" <ddevore_at_duckhouse.us>
> Date: Fri, July 25, 2008 7:23 am
> To: users_at_glassfish.dev.java.net <mailto:users_at_glassfish.dev.java.net>
>
> I have run so many tests with this that they all sorta run together.
> I thought I tried that but when a database error occurred I thought
> it made its way up anyway. I will try again today and let you know
> what the results are.
>
> -------- Original Message --------
> Subject: RE: Keeping a timer alive
> From: "Manfred Riem" <mriem_at_manorrock.org>
> Date: Thu, July 24, 2008 11:44 pm
> To: < <mailto:users_at_glassfish.dev.java>users_at_glassfish.dev.java
> <mailto:users_at_glassfish.dev.java>.net>
>
> You can access to the TimerService API directly from your
> handler code. If you handle any
> Throwable yourself, you should be able to cancel the current
> Timer and create a new one
> with the parameters you want.
>
> Manfred
>
> *From:* Dru Devore [ <mailto:ddevore_at_duckhouse.us>
> <mailto:ddevore_at_duckhouse.us>mailto:ddevore_at_duckhouse.us]
> *Sent:* Thursday, July 24, 2008 9:17 PM
> *To:*
> <mailto:users_at_glassfish.dev.java.net>users_at_glassfish.dev.java.net
> <mailto:users_at_glassfish.dev.java.net>
> *Subject:* RE: Keeping a timer alive
>
> I found it configurable through the admin but I can't seem to
> see anyway of doing it programmatically, if it is even possible.
>
> I must thank you for all your help. This has been one of the
> most helpful threads I have ever put on an email list.
>
> Thanks
>
>
>
>
>
> -------- Original Message --------
> Subject: RE: Keeping a timer alive
> From: "Manfred Riem" <mriem_at_manorrock.org>
> Date: Thu, July 24, 2008 10:24 pm
> To: < <mailto:users_at_glassfish.dev.java>
> <mailto:users_at_glassfish.dev.java>users_at_glassfish.dev.java
> <mailto:users_at_glassfish.dev.java>.net>
>
> And did you find your answer?
>
> *From:* Dru Devore [__ <mailto:ddevore_at_duckhouse.us>_
> <mailto:ddevore_at_duckhouse.us>
> <mailto:ddevore_at_duckhouse.us>mailto:ddevore_at_duckhouse.us___]
> *Sent:* Thursday, July 24, 2008 3:38 PM
> *To:* __ <mailto:users_at_glassfish.dev.java.net>_
> <mailto:users_at_glassfish.dev.java.net>users_at_glassfish.dev.java.net
> <mailto:users_at_glassfish.dev.java.net>_
> *Subject:* RE: Keeping a timer alive
>
> Wait wait don't answer yet.. I did one more search after sending
> this message and I think I found the answer.
>
>
>
> -------- Original Message --------
> Subject: RE: Keeping a timer alive
> From: "Dru Devore" <ddevore_at_duckhouse.us>
> Date: Thu, July 24, 2008 5:36 pm
> To: __ <mailto:users_at_glassfish.dev.java.net>_
> <mailto:users_at_glassfish.dev.java.net>users_at_glassfish.dev.java.net
> <mailto:users_at_glassfish.dev.java.net>_
>
> I have been running some tests and have found that the server
> will expung the timer "EJB5119 Expunging timer" if it fails two
> times and the first time it fails it turns right back around and
> tries again, not on the schedule. This application queries a
> database so if it errors out it will not be fixed before it will
> hit it the second time and fail for good. Is there a way I can
> configure this action. Like tell it to attempt more times and
> only on the scheduled times. Or anything that will allow me to
> check resources and recover if possible?
>
> I must say you are being a BIG help too bad we didn't talk
> before I implemented the other "solution".
>
>
>
> -------- Original Message --------
> Subject: RE: Keeping a timer alive
> From: "Manfred Riem" <mriem_at_manorrock.org>
> Date: Thu, July 24, 2008 4:56 pm
> To: <__ <mailto:users_at_glassfish.dev.java>_
> <mailto:users_at_glassfish.dev.java>users_at_glassfish.dev.java
> <mailto:users_at_glassfish.dev.java>_.net>
>
> This is actually part of the EJB spec. And it is implemented ;)
>
> And yes it will retrigger.
>
> Manfred
>
> *From:* Dru Devore [__ <mailto:ddevore_at_duckhouse.us>_
> <mailto:ddevore_at_duckhouse.us>
> <mailto:ddevore_at_duckhouse.us>mailto:ddevore_at_duckhouse.us___]
> *Sent:* Thursday, July 24, 2008 2:15 PM
> *To:* __ <mailto:users_at_glassfish.dev.java.net>_
> <mailto:users_at_glassfish.dev.java.net>users_at_glassfish.dev.java.net
> <mailto:users_at_glassfish.dev.java.net>_
> *Subject:* RE: Keeping a timer alive
>
> Oh my...that was so much easier than I thought. With little work
> and it just works.
>
> I am reading elsewhere that the timing in EJB 3 is still not
> implemented which, if I remember correctly, is why I didn't do
> it this way from the start. But if you use this example:
> __
>
<http://www.diotalevi.com/weblog/2006/10/30/java-ee-in-the-trenches-how-to-u
se-the-timerservice-and-write-a-timer-session-bean/>_
>
<http://www.diotalevi.com/weblog/2006/10/30/java-ee-in-the-trenches-how-to-u
se-the-timerservice-and-write-a-timer-session-bean/>
>
<http://www.diotalevi.com/weblog/2006/10/30/java-ee-in-the-trenches-how-to-u
se-the-timerservice-and-write-a-timer-session-bean/>http://www.diotalevi.com
/weblog/2006/10/30/java-ee-in-the-trenches-how-to-use-the-timerservice-and-w
rite-a-timer-session-bean/_
> Everything for what I need is right there.
>
> One last question though. If something goes horribly wrong with
> an execution of the task and it dies, runtime exception or
> something, am I right in saying that it will pickup with the
> next one? (I am going to be testing it if you don't know for sure)
>
> Thanks for the suggestion.
>
>
>
>
>
>
> -------- Original Message --------
> Subject: RE: Keeping a timer alive
> From: "Manfred Riem" <mriem_at_manorrock.org>
> Date: Thu, July 24, 2008 12:48 pm
> To: <__ <mailto:users_at_glassfish.dev.java>_
> <mailto:users_at_glassfish.dev.java>users_at_glassfish.dev.java
> <mailto:users_at_glassfish.dev.java>_.net>
>
> Hi Dru,
>
> While it might seem to be a lot of overhead it is J2EE standard.
> Spawning a thread
> in a servlet is not. The question is if you want to deal with
> race conditions that are
> associated with threading.
>
> Manfred
>
> *From:* Dru Devore [_ <mailto:ddevore_at_duckhouse.us>
> <mailto:ddevore_at_duckhouse.us>
> <mailto:ddevore_at_duckhouse.us>mailto:ddevore_at_duckhouse.us___]
> *Sent:* Thursday, July 24, 2008 10:31 AM
> *To:* _ <mailto:users_at_glassfish.dev.java.net>
> <mailto:users_at_glassfish.dev.java.net>users_at_glassfish.dev.java.net
> <mailto:users_at_glassfish.dev.java.net>_
> *Subject:* RE: Keeping a timer alive
>
> I am sure I can make this work though all I really need is a a
> timer that kicks off a method every X seconds and is managed by
> someone. Using the servlet I simply had a thread that would
> sleep for X seconds but I didn't have any management, which
> could be done if I need to.
>
> Looking at the EJB timer service it looks like a lot of overhead
> and work to do a run this every X seconds. Is there a solution I
> am missing or do I need to create a monitor thread for my run
> every x seconds thread?
>
>
>
>
>
>
>
> -------- Original Message --------
> Subject: RE: Keeping a timer alive
> From: "Manfred Riem" <mriem_at_manorrock.org>
> Date: Thu, July 24, 2008 10:25 am
> To: <_ <mailto:users_at_glassfish.dev.java>
> <mailto:users_at_glassfish.dev.java>users_at_glassfish.dev.java
> <mailto:users_at_glassfish.dev.java>_.net>
>
> The following URLs come to mind:
>
> _ <http://java-x.blogspot.com/2007/01/ejb-3-timer-service.html>
> <http://java-x.blogspot.com/2007/01/ejb-3-timer-service.html>
>
<http://java-x.blogspot.com/2007/01/ejb-3-timer-service.html>http://java-x.b
logspot.com/2007/01/ejb-3-timer-service.html_
> _ <http://docs.sun.com/app/docs/doc/820-4496/beahw?a=view>
> <http://docs.sun.com/app/docs/doc/820-4496/beahw?a=view>
>
<http://docs.sun.com/app/docs/doc/820-4496/beahw?a=view>http://docs.sun.com/
app/docs/doc/820-4496/beahw?a=view_
> _
>
<http://www.diotalevi.com/weblog/2006/10/30/java-ee-in-the-trenches-how-to-u
se-the-timerservice-and-write-a-timer-session-bean/>
>
<http://www.diotalevi.com/weblog/2006/10/30/java-ee-in-the-trenches-how-to-u
se-the-timerservice-and-write-a-timer-session-bean/>
>
<http://www.diotalevi.com/weblog/2006/10/30/java-ee-in-the-trenches-how-to-u
se-the-timerservice-and-write-a-timer-session-bean/>http://www.diotalevi.com
/weblog/2006/10/30/java-ee-in-the-trenches-how-to-use-the-timerservice-and-w
rite-a-timer-session-bean/_
> _ <http://java.sun.com/javaee/5/docs/tutorial/doc/bnboy.html>
> <http://java.sun.com/javaee/5/docs/tutorial/doc/bnboy.html>
>
<http://java.sun.com/javaee/5/docs/tutorial/doc/bnboy.html>http://java.sun.c
om/javaee/5/docs/tutorial/doc/bnboy.html_
>
> Hope this helps,
> Manfred
>
> *From:* Dru Devore [_ <mailto:ddevore_at_duckhouse.us>
> <mailto:ddevore_at_duckhouse.us>
> <mailto:ddevore_at_duckhouse.us>mailto:ddevore_at_duckhouse.us___]
> *Sent:* Thursday, July 24, 2008 8:18 AM
> *To:* _ <mailto:users_at_glassfish.dev.java.net>
> <mailto:users_at_glassfish.dev.java.net>users_at_glassfish.dev.java.net
> <mailto:users_at_glassfish.dev.java.net>_
> *Subject:* RE: Keeping a timer alive
>
> When it was written I am sure there was but I can't think of any
> presently.
>
> I am looking for examples/tutorials do you have any good ones?
>
>
>
>
>
>
>
> -------- Original Message --------
> Subject: RE: Keeping a timer alive
> From: "Manfred Riem" <mriem_at_manorrock.org>
> Date: Thu, July 24, 2008 9:55 am
> To: <_ <mailto:users_at_glassfish.dev.java>
> <mailto:users_at_glassfish.dev.java>users_at_glassfish.dev.java
> <mailto:users_at_glassfish.dev.java>_.net>
>
> Any reason why you are not EJB timer service?
>
> *From:* Dru Devore [_ <mailto:ddevore_at_duckhouse.us>
> <mailto:ddevore_at_duckhouse.us>
> <mailto:ddevore_at_duckhouse.us>mailto:ddevore_at_duckhouse.us___]
> *Sent:* Thursday, July 24, 2008 7:52 AM
> *To:* glassfish_user
> *Subject:* Keeping a timer alive
>
>
> I have a timer that is running in a servlet in Glassfish and I
> encountered a problem with it last night, the timer thread
> stopped. I need a way to ensure the timer is running and if it
> does stop, to restart it. Is there a way to have the server
> monitor this or am I hoping for too much?
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: _
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>
>
<mailto:users-unsubscribe_at_glassfish.dev.java.net>users-unsubscribe_at_glassfish
.dev.java.net
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>_ For
> additional commands, e-mail: _
> <mailto:users-help_at_glassfish.dev.java.net>
>
<mailto:users-help_at_glassfish.dev.java.net>users-help_at_glassfish.dev.java.net
> <mailto:users-help_at_glassfish.dev.java.net>_
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: _
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>
>
<mailto:users-unsubscribe_at_glassfish.dev.java.net>users-unsubscribe_at_glassfish
.dev.java.net
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>_ For
> additional commands, e-mail: _
> <mailto:users-help_at_glassfish.dev.java.net>
>
<mailto:users-help_at_glassfish.dev.java.net>users-help_at_glassfish.dev.java.net
> <mailto:users-help_at_glassfish.dev.java.net>_
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: _
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>
>
<mailto:users-unsubscribe_at_glassfish.dev.java.net>users-unsubscribe_at_glassfish
.dev.java.net
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>_ For
> additional commands, e-mail: _
> <mailto:users-help_at_glassfish.dev.java.net>
>
<mailto:users-help_at_glassfish.dev.java.net>users-help_at_glassfish.dev.java.net
> <mailto:users-help_at_glassfish.dev.java.net>_
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: __
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>_
>
<mailto:users-unsubscribe_at_glassfish.dev.java.net>users-unsubscribe_at_glassfish
.dev.java.net
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>_ For
> additional commands, e-mail: __
> <mailto:users-help_at_glassfish.dev.java.net>_
>
<mailto:users-help_at_glassfish.dev.java.net>users-help_at_glassfish.dev.java.net
> <mailto:users-help_at_glassfish.dev.java.net>_
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: __
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>_
>
<mailto:users-unsubscribe_at_glassfish.dev.java.net>users-unsubscribe_at_glassfish
.dev.java.net
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>_ For
> additional commands, e-mail: __
> <mailto:users-help_at_glassfish.dev.java.net>_
>
<mailto:users-help_at_glassfish.dev.java.net>users-help_at_glassfish.dev.java.net
> <mailto:users-help_at_glassfish.dev.java.net>_
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: __
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>_
>
<mailto:users-unsubscribe_at_glassfish.dev.java.net>users-unsubscribe_at_glassfish
.dev.java.net
> <mailto:users-unsubscribe_at_glassfish.dev.java.net>_ For
> additional commands, e-mail: __
> <mailto:users-help_at_glassfish.dev.java.net>_
>
<mailto:users-help_at_glassfish.dev.java.net>users-help_at_glassfish.dev.java.net
> <mailto:users-help_at_glassfish.dev.java.net>_
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
>
<mailto:users-unsubscribe_at_glassfish.dev.java.net>users-unsubscribe_at_glassfish
.dev.java.net
> <mailto:users-unsubscribe_at_glassfish.dev.java.net> For additional
> commands, e-mail:
>
<mailto:users-help_at_glassfish.dev.java.net>users-help_at_glassfish.dev.java.net
> <mailto:users-help_at_glassfish.dev.java.net>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> <mailto:users-unsubscribe_at_glassfish.dev.java.net> For additional
> commands, e-mail: users-help_at_glassfish.dev.java.net
> <mailto:users-help_at_glassfish.dev.java.net>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net For
> additional commands, e-mail: users-help_at_glassfish.dev.java.net


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net