aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Concurrency for MDB's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Concurrency for MDB Watch "Concurrency for MDB New topic

Concurrency for MDB's

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243


The following lines are from O'Reilly's book,

In MDB's concurrency refers to the processing of more than one message at a time. If MDB's could process only a single message at a time, then they would practically be useless in a real-world application because they could not handle heavy message loads.

They show a diagram where in three message arrives and three instances of MDB's are pulled out from the pool to process these messages. My question here is doesn"t concurrency mean processing of the all three messages by a single MDB instance? Please advice guys!

SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Aryan Khan
Ranch Hand

Joined: Sep 12, 2004
Posts: 290

No, that would be serial processing. MDB's can process multiple messages at the same time by using the MDB pool. So it is concurrent processing.


Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243

so concurrency here does not mean thread safety?
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697

Generally speaking for queues, you could have a pool of MDBs each receiving a subset of the messages coming in but there are two things to be worried about:

- You can't control order of messages in queues. You never can. You may process messages that are newer than some old messageswaiting to be processed (even in the case of a single MDB in the pool this can happen).

- You can't control which MDB in the pool gets messages so you need some kind of persistent storage device like a database coordinating multi-step communications such as negotiating a customer transaction.

And if you follow the EJB spec, everything is thread safe. The only time you violate thread safe is if you spawn your own threads.
[ September 28, 2008: Message edited by: Scott Selikoff ]

My Blog: Down Home Country Coding with Scott Selikoff
I agree. Here's the link:
subject: Concurrency for MDB's
Similar Threads
Stopping thread in stateful session bean
Messaging solution for parallel processing
How to Delete Messages from Jboss Queue during jboss shut down?
Wait, notify alternative
Consuming JMS messages in FIFO order