File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes JMS and MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JMS and MDB" Watch "JMS and MDB" New topic


Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Hi All,

When to usa JMS as opposed to MDB?
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Hi Mary,

EJB components (other than MDB), can act as JMS producers creating and sending messages to JMS destinations. However they cannot act as an asynchronous JMS consumers. A SLSB can use JMS API and waiting for a message, but this synchronous operation could block the thread indefinitely. This was the reason why MDB were added to EJB2.0 in the first place anyway: to allow J2EE component to asynchronously process JMS message. Besides is much easier to develop a MDB consumer than using JMS API and write your own.
As for your question is very hard for me to imagine why to use JMS API when building a J2EE application; it might be a good solution for integrating with other queuing services, like IBM MQSeries, or having a simple JMS client application, but that�s another story. One reason not to use MDB might be the need to implement a JMS consumer that processes messages synchronously. But in that case why to use JMS in the first place anyway?
I hope this will help.

I think, therefore I exist -- Rene Descartes
Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Thx for your reply

I got it
I agree. Here's the link:
subject: JMS and MDB
It's not a secret anymore!