Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Message Facade (Message Driven Bean)

 
Anna Madhusudhanan Natanagopalan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
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.
Nimo.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Anna Madhusudhanan Natanagopalan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nimo and Roger
Thank you so much for your great explanation.
Thanks and regards
Anna Madhusudhanan.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic