• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

JMS request/ Response Model using MDB.  RSS feed

 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!