|
Home > Archive > EAserver > March 2005 > ThreadManager and stateful EJB:s
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
ThreadManager and stateful EJB:s
|
|
| Henrik Glimberg 2005-03-30, 7:08 pm |
| I have a stateless session EJB that needs to spawn a thread with some=20
input parameters.
I have solved this by using the ThreadManager, and initiating a stateful=20
session EJB and calling a couple of set methods before handing it over=20
to the ThreadManager, and this seems to work really nice.
But after doing an amount of test calls to this thread I noticed that=20
the number of active instances of my "thread object" always increased=20
and never seemed to decrease (watching the counter on the component i=20
jagman).
So I added some debug output to the ejbRemove and ejbPassivate methods -=20
and it seems that these methods never get called from the ThreadManager=20
- and so the garbage keeper never cleans out these objects.
Is this because I?ve missed to code some special routine to terminate my=20
thread or is it just because I haven?t reached the container limit where=20
the garbage keeping starts ?
My run() method just calls a private method in my "thread" component and=20
then returns to the Threadmanager, and I thought the ThreadManager would=20
call ejbRemove after the thread had terminated....
/Henrik
| |
| Jan Radl 2005-03-30, 7:08 pm |
| Henrik Glimberg wrote:
> I have a stateless session EJB that needs to spawn a thread with some
> input parameters.
> I have solved this by using the ThreadManager, and initiating a stateful
> session EJB and calling a couple of set methods before handing it over
> to the ThreadManager, and this seems to work really nice.
> But after doing an amount of test calls to this thread I noticed that
> the number of active instances of my "thread object" always increased
> and never seemed to decrease (watching the counter on the component i
> jagman).
> So I added some debug output to the ejbRemove and ejbPassivate methods -
> and it seems that these methods never get called from the ThreadManager
> - and so the garbage keeper never cleans out these objects.
>
> Is this because I?ve missed to code some special routine to terminate my
> thread or is it just because I haven?t reached the container limit where
> the garbage keeping starts ?
>
> My run() method just calls a private method in my "thread" component and
> then returns to the Threadmanager, and I thought the ThreadManager would
> call ejbRemove after the thread had terminated....
>
> /Henrik
Using threads in EJB is not best practise. It is better to start threads
in client call with create number of SSB and run methods on this beans.
Jan
| |
| Henrik Glimberg 2005-03-30, 7:08 pm |
| In article <4241983d$1@forums-1-dub>, radl@fss.cz says...
> Henrik Glimberg wrote:
......
-=20[color=darkred]
=20[color=darkred]
> Using threads in EJB is not best practise. It is better to start threads=
=20
> in client call with create number of SSB and run methods on this beans.
>=20
> Jan
>=20
>=20
This problem is for a server side only application, and I don?t want to=20
have a client outside the EAS just to create the threads when someone=20
added the threadmanager to take care of this... seems like a wast not to=20
use it when it is there....
/Henrik
| |
| Jonathan Baker [Sybase] 2005-03-30, 7:09 pm |
| You could try using MDB (Message Driven Beans) instead. The MDB system
is an "official" asynchronous threading model, and the beans called by
the message service should act normally.
Jonathan
Henrik Glimberg wrote:
> In article <4241983d$1@forums-1-dub>, radl@fss.cz says...
>
>
> ......
>
>
> This problem is for a server side only application, and I don?t want to
> have a client outside the EAS just to create the threads when someone
> added the threadmanager to take care of this... seems like a wast not to
> use it when it is there....
> /Henrik
|
|
|
|
|