users@glassfish.java.net

Re: Queueing jobs for processing in their own thread/transaction?

From: Dobes Vandermeer <dobesv_at_gmail.com>
Date: Mon, 9 Feb 2009 20:50:37 -0800 (PST)

It might be impossible. I've given up on the JMS stuff since it was buggy
and the WorkManager doesn't support transactions as far as I can tell.
However, now I have a new issue - when my timers run (I run a bunch of them
to keep operation separate) the server and database start paging due to high
memory use. Apparently I *do* need a way to restrict the number of these
threads that are running.

Maybe I'll go poking around in the glassfish source code and see if there's
some private API I can use to workaround this and create a new transactional
session in my Work instance somehow. I already poked around a bit but got
scared of the code there, the code to invoke a timeout, which I thought
would be a good example, seems to be pretty involved stuff. Nevertheless,
having a utility class to run these jobs in a thread pool of my choosing
would be very, very useful so it might be worth some brain pain to decipher
the complexity of that subsystem.



Brian Repko wrote:
>
>
> Interesting, I'm not using EJB3.0 - I'm using Spring so all I need is to
> get my ApplicationContext and I'm off and running. The LazyInitEx is
> definately related to walking the object graph after the session is
> closed.
>
> My guess is that putting Work on the queue doesn't get container objects
> injected into it - you will probably need to get them some other way.
>
> Sorry - I don't know how to do that - anyone else?
>
> Brian
>
> ----- Original message -----
> From: "Dobes Vandermeer" <dobesv_at_gmail.com>
> To: users_at_glassfish.dev.java.net
> Date: Tue, 3 Feb 2009 11:39:37 -0800 (PST)
> Subject: Re: Queueing jobs for processing in their own thread/transaction?
>
>
> Okay, this looked really good but I'm having trouble accessing the
> database
> inside my Work object.
>
> The errors I'm getting are:
>
> org.hibernate.LazyInitializationException: could not initialize proxy - no
> Session
>
> or
>
> IllegalArgumentException: entity not in the persistence context
>
> Strangely I am not re-using objects from the other thread (that I know of)
> I
> get the object using em.get() and then try to use that object.
>
> Is there anything special I need to do in the Work object to set up the
> persistence context and session? Does it need to construct its own copy
> of
> the stateless beans and EntityManager somehow?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>

-- 
View this message in context: http://www.nabble.com/Queueing-jobs-for-processing-in-their-own-thread-transaction--tp21795170p21927689.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.