wood burning stoves*
The moose likes EJB and other Java EE Technologies and the fly likes JMS request/ Response Model using MDB. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JMS request/ Response Model using MDB." Watch "JMS request/ Response Model using MDB." New topic
Author

JMS request/ Response Model using MDB.

Mohammed Yousuff
Ranch Hand

Joined: Oct 17, 2007
Posts: 198
I am trying use JMS for request/response model using MDB, i.e when a client sent Message to Server (Here is our MDB). The MDB should send the response back to the same Client which sent the messge.

I found some examples in net which explains the same scnario but both client & server are J2SE.But what I am try is my server should be MDB Bean.
I appriciate if you can throw some lights… please let me know if any example code is avilable.

My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
Piyush Kr
Greenhorn

Joined: Aug 13, 2010
Posts: 1
[color=darkblue][size=12]Hi, I deployed an MDB a few days ago on weblogic and created a simple java client that produced message and the MDB consumed it.

The code available on the internet is for creating message producers and consumers using JMS API which is not what you want.

Following are the steps which you need to do for what you want -

1. Create an MDB (a born message consumer).
2. Make sure that it implements MessageListener interface in addition to MessageDrivenBean interface.
3. Write your code (for what you want to do with the messsage received by the MDB)
in the onMessage(Message m) method. For example -


4. If you want your MDB to talk with the client which sent the message(which is what MDB's are not made for)
you can write JMS producer code also, in the onMessage method.

5. Create a ConnectionFactory and a Queue(or Topic) in your JMS server (provided by J2EE app server).
(In weblogic I created JMS server and a ConnectionFactory and a Queue using admin console)
6. In deployment descriptor add entries for JNDI names of the ConnectionFactory and the Queue.
7. Deploy the bean.
8. Create a message producer client by using the standard JMS api as,


9. If you want this client to recieve back the message, create a message consumer also, code is pretty similar to that shown above for creating a message producer.
10. I needed wlclient.jar (in the classpath) since i did it in weblogic. For other servers the jar file and the second argument in the statements,

will change.
11. In above code, piyush.connectionfactory and piyush.testmessagequeue are JNDI names of the resources created on the JMS server.

Try doing that. Hope it would help.

[/size] [/color]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMS request/ Response Model using MDB.
 
Similar Threads
Camel : Request –Reply using JMS
JMS - Achieving gaurateed sending of messages in the Queue
MDB Question re: WEB tier vs. EJB tier
JMS Load Balancing In Websphere V7.0
JMS and Webservices