• 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
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Synchronous to asynchronous mapping

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
and POOF! You're gone! But look, this tiny ad is still here:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic