• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MDB with MessageConsumers

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Within an MDB I'm trying to resend a received Message to
second MDB and wait for a response (using a MessageConsumer).

I'm doing this inside the body of the onMessage() method of the first MDB.
There, a Temporary Queue is created and attached to the Message using
setJMSReplyTo(). This TQueue will be used by the second MDB to return
the answer back to the first MDB.

Has anybody tried this mechanism between MDB and worked ok? In my case
it is failing; basically the original source of the message times out
waiting for a response.

I wonder if the MDB's life-cycle prevents it from sending and then
waiting for a response.

Cheers.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Havent tried this specific scenario before. Are you using transacted connection factory to send the message to the second MDB from the first MDB? Also, does the control ever reach the onMessage method of the second MDB? If it doesnt reach then i guess because the transaction of your onMessage method in 1st MDB is not yet committed, the message is never really sent to the queue and hence the second MDB is never invoked(i am assuming that you are using transacted connection factory)
 
Blue Rider Abc Murnau
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jaikiran,

I think the problem lies in that the message is not effectively sent to
the Queue until onMessage() has finished in the 1st MDB. This would prevent
this MDB to have a consumer waiting for a response inside this method.

The pseudo-code of what I was trying to do is:
onMessage(Message myMsg){
1.- CREATE TEMPORARY QUEUE AND USE IT IN myMsg.setJMSReplyTo()
2.- SEND myMsg TO 2nd MDB
3.- CONSUMER.RECEIVE(TIMEOUT_MILLIS) // wait for a response from 2nd MDB
4.- DONE
}

I don't think now that a message can be sent and then wait for a
response in the same onMessage body. The consumer is effectively blocking
the execution of onMessage().

What do you think?

Cheers
BR
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One solution might be to have Bean Managed Transaction on your MDB. So your code in the onMessage would look like:



Effectively, after sending the message to the queue for 2nd MDB to pickup, you are committing the transaction and as a result the message will be delivered to MDB2.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic