tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dain Sundstrom <d...@iq80.com>
Subject Re: Using the Timer Service (in Geronimo)
Date Fri, 29 Aug 2008 15:51:24 GMT
On Aug 28, 2008, at 10:13 PM, Jay D. McHugh wrote:

> Hello all,
>
> I have a chain of stateless session beans that are being triggered by
> the timer service in Geronimo.
>
> But, even though they are being created with single expirations - they
> do not seem to be getting destroyed until the entire chain finishes.
>
> For clarity here is what I mean by chain:
>
> Timer1 creates a timer object for Timer2 with a single expiration.
> Timer2 creates a timer object for Timer3 with a single expiration.
> .
> .
> .
> TimerX creates a timer object for TimerY with a single expiration.
>
> Each successive timer is created as the '@Timeout' method of its
> 'parent' is finishing with an expiration date/time one minute in the  
> future.
>
> Each of the timers is performing some pretty intense data cleansing
> work.  So, there is a lot of memory getting allocated at each step.   
> So
> much so that even with no other activity going on, the server often
> crashes (runs out of memory or becomes unable to make new database
> connections) before it is able to get to the end of the chain.
>
> I added a 'finalize' method and a '@PreDestroy' method for each of the
> timers and none of them have been called yet even though fourteen  
> timers
> have run and printed out a message to the console indicating that the
> 'timeout' method has gotten to the end.
>
> Actually, I just got a heap space error and finally one of the classes
> got finalized (two now) but it looks like that is probably all that  
> will
> finish 'cleanly'.
>
> Is there a way to nudge those classes so that they finalize?

Which instance do you want to be destroyed?  If you mean the stateless  
bean, they are pooled and typically only destroyed when VM shutdown.   
You can disable the pool by setting PoolSize to 0 in which case a new  
instance will be created and destroyed for each method invocation.   
Stateless EJB creation and destruction is not a particularly expensive  
process unless your bean is doing a lot of work in the create/destroy  
callbacks.

Alternatively, you could null out all of your fields before the timer  
method exits (or even better as soon as you are done with the data).   
This is the most portable way to handle this.

-dain

Mime
View raw message