wood burning stoves*
The moose likes Java in General and the fly likes Synchronous to asynchronous mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Synchronous to asynchronous mapping" Watch "Synchronous to asynchronous mapping" New topic
Author

Synchronous to asynchronous mapping

Dasun Perera
Greenhorn

Joined: Jul 09, 2002
Posts: 13
Hi,

Session bean has a method which sends an asynchronous message (MQ) to retrieve some data from a legacy system. Reply also comes as a MQ message and this data need to be returned from teh above session bean method. Anybody have any idea of what is thebest way to implement this?

Dasun Perera
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
If you go to native MQ APIs there is a getAndWait method that, um, waits and gets. We use it for synchronous request-response MQ all the time. If you use a JMS wrapper over MQ I think there are synchronous methods, too. Use these solid APIs if you possibly can.

If you have to roll your own make use of the correlation id. MQ gives you this id when it sends a message and includes the id on the response so you can match things up. I'm in deep water for me here, but maybe put some object in a shared Map with correlation id as key then wait() on it. The event handler for the asynchronous response could get the object by key and notify(). Does that kind of thing makes sense?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronous to asynchronous mapping
 
Similar Threads
Is this a good way of using EJBs?
Need to synchronize objet in a MDB (Not resolved)
pushing real-time data to screen
Mainframe client
asynchronous jms consumer