-
1. Re: Multithreading using MDB
ssmyka Jun 21, 2005 5:10 PM (in response to sameerbkk)One possibility to communicate with the MDB Thread would be having a flag (in Database, static field, file ...). The Thread on each iteration would check this flag and interrupt itself if set to false.
Cheers,
Szymon Smyka -
2. Re: Multithreading using MDB
halkw Aug 1, 2005 4:51 AM (in response to sameerbkk)I think that it's concerned at the MDB in duplicate.
I recommend that you certain whether the Bean is Binded
For example, You can check whether the thread prosess is running or aborted as the sample code below
----------------------------------------------------------
...
if( cache.containKey(JNDIName) )
{
queueFactory=(QueueConnectionFactory)cache.get("JNDIName");
}
else
{
queueFactory=(QueueConnectionFactory)initialContext.lookup("JNDIName");
}
...
----------------------------------------------------------
plz refer to this docs
http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html -
3. Re: Multithreading using MDB
halkw Aug 1, 2005 4:56 AM (in response to sameerbkk)Sorry I maybe guess wrong; I understood it in error;
-
4. Re: Multithreading using MDB
jasperboy Sep 22, 2005 2:48 PM (in response to sameerbkk)If it's a matter of sending a signal to terminate the MDB - why not get each single-threaded MDB to check periodically another app-wide queue filtered against a pre--agreed ID sent from the original client (normal JMS consumption as opposed to through the OnMessage() interface) to see if it should terminate early ?
That way your clients can simply send termination signals to one queue for a specific consumer. -
5. Re: Multithreading using MDB
nick.hynes Nov 17, 2005 8:36 PM (in response to sameerbkk)Initially the plan was to use MDB (Message Driven Beans) to spawn mutliple threads and get the task done.
IIRC the J2EE specification forbids you from spawning threads inside the J2EE container, so you need to be aware that your application may not port across different servers in a consistent way. For instance security permissions, contexts etc. may not be consistent across different vendors or server versions.
An alternative approach is to create a large pool of MDB, and make each JMS message a separate request. We considered this approach, but decided that it wouldn't meet our performance metrics.
P.S. If you do get an approach like this working, I'd be interested to know how it does perform and scale in practice... there is a lot of theory on this, but I haven't seen any hard data one way or the other. -
6. Re: Multithreading using MDB
patrick_ibg Feb 7, 2006 11:55 PM (in response to sameerbkk)
This is such a basic server-side threading construct, the difficulty in implementing in EJB shows the immaturity of the standard (IMHO).
From what I understand, however, they might try to get asynchronous EJB3 calls in the next iteration (3.1) of the spec.
In the meantime, if you don't mind doing something JBoss-specific, you could look at asynchronous proxies:
http://docs.jboss.org/ejb3/app-server/tutorial/asynch/asynch.html
Another JBoss extension, Service POJOs, might also help do the trick:
http://docs.jboss.org/ejb3/app-server/tutorial/service/service.html
I think for what you are trying to do, you want a "worker" SFSB that implements the long-running job. It will keep state internally, but it exposes getter methods that allow clients to peek into the state. Then, you call it via another "facade" SFSB via an asynchronous proxy. At least this way you protect the end-client from calling JBoss specific code.