The moose likes EJB and other Java EE Technologies and the fly likes Message Facade (Message Driven Bean) 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 "Message Facade (Message Driven Bean)" Watch "Message Facade (Message Driven Bean)" New topic

Message Facade (Message Driven Bean)

Anna Madhusudhanan Natanagopalan

Joined: Apr 05, 2004
Posts: 25
Hi In the Message facade pattern, the client send the JMS to the Message drive beans. how can he call the MDB? Becaseu there is no client-view in the MDB. how it is possible.
Thanks and regards
Anna Madhusudhanan
C. Nimo
Ranch Hand

Joined: Mar 23, 2004
Posts: 82
An MDB is a special type of EJB - it doesn't have any method for the client to call. More than that - it doesn't have any method for anyone to call.
When you deploy the MDB, you specify the destination (queue/topic) that it will listen on. From then on, it it the application server's responsibility to call this MDB's onMessage() method when a message arrives at that destination.
This contract is the only thing that you can rely on. Nothing else. Therefore, when you use an MDB to listen on a destination, all you do is program that onMessage() method to do the work for you. From this method you may call other EJBs, log stuff to file, send messages to other destinations, etc.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
No client ever talks to an EJB. A client sends message to a destination, which is either a queue or a topic. For asynchronous messaging, the Container will invoke the MessageListener's onMessage() method. If the consumer is an MDB, which is a type of MessageListener, the Container will pull an MDB instance from the pool to service the call.
The MDB is a MessageListener, kind of like an event listener but receives messages of type javax.jms.Message (passed into the onMessage() method) rather than events.

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Anna Madhusudhanan Natanagopalan

Joined: Apr 05, 2004
Posts: 25
Hi Nimo and Roger
Thank you so much for your great explanation.
Thanks and regards
Anna Madhusudhanan.
I agree. Here's the link:
subject: Message Facade (Message Driven Bean)
It's not a secret anymore!