Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Help on Message Driven Beans

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Right now we are using SessionBean to read response from third party vendor.
Client can recieve the required repsonse by calling corresponding remote method.
I am trying to implement Message Driven Bean to read response from third party vendor.
How does client will recive response from message driven bean?
MDB have only the following method:

public void onMessage(Message message) {

}

But this not returning any response.

I have the following method in the Session Bean.

public List getResult(String str){
.............
return result;
}

Now client willl recive the reponse as List by calling getResult(String) method.
If I want to implement same thing using MDB bean how do I write MDB such that
client will recieve the response as List by calling MDB bean method.

Any help please...........

Thanks.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A MDB can never be called by a client. The only thing you can do in your MDB is to send a Message to the client through the message service.

/Severin
 
suchi penukudi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Severin,

How do I send message to client using messaging servive. Any example please.
I want to send List to client using message service.

Thanks.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, you have to have a JMS Server installed.

2. Install a queue or topic. Preferably queue in your example, just to give a point-to-point communication.

3. Then you have to obtain a Connection Factory Resource, where you are going to receive a Session for the queue.

4. Send a message for the specific queue.

5. When you deployed your MDB you specify the queue, to listen for.

This way, your MDB act as a message listener.
As you can see, there is no direct access of the client to the Enterprise Bean. We can obtain some benefits with this approach.

hope this help!

PD. For more specific implementation details, go over:
http://java.sun.com

Gabriel
(SCJP, SCWCD, pursuing SCBCD)
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do exactly what you are talking about. Here is the MDB




When the message shows up on the queue, the bean is triggered and places the response into an application level cache. The user's viewing application looks to the cache for the message, not the queue.


The tracking id is needed since concurrent users may get responses from the same queue -- this could be the session id.

The caching is implemented by either an entity bean or database or other method. The thing here is that you need to manage the messages within your application as they come off of the queue. The user page then checks the cache for responses, and removes any that are read. Also, the cache implementation lets returned messages in the cache time-out and are deleted auto-magically.

Finally, the parser simply knows how to read the returned message and find the tracking id. You could also use a property on the message, something like this:


Your publisher needs to set that property for that solution to work.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic