Hi, Could anyone please advise on a recommended way to register an *asyncrhounous* message listener, using a message selector that relies on *message id* ? Posted a similar question on synchronious listeners, and it worked -thanks .However, with asynchronous mode, I'm having a race condition, because message ID is only known after you've sent it; by that time, it's too late to register the listener since it may missed the reply.
Thank you very much for taking a look.
Joined: Nov 13, 2002
Sorry, correction. I was of course trying to listen for incoming messages with *correlation* id equals to the original request's *message* id, so the selector should be:
I'm having a hard time figuring out what you want. Why do you want to set up an asynchronous listener for one message? If you filter according to the correlation id, then why would you ever get more than one message in this queue? Are you expecting to destroy the listener after it gets its one message?
Sounds like instead you want to use a temporary queue and the reply-to-queue feature if you're only expecting one message back. In that case, just create a temporary queue, set the reply-to-queue property on your message (setJMSReplyTo) to be the temporary queue, and then create an asynchronous listener on the temporary queue. That way you don't have to mess with the correlation ID at all.