|
|
jmsTemplate.receiveSelected returns null
Hi
I'm new to this forum and new to Spring and JMS as well.
I'm facing a problem with using receiveSelected() method. When I use a selector, the reply message is null and when I use the receive() method without specifying the selector, then I get the message back from the same reply queue.
I tried to select the reply message on my app specific Correlation Id as well as MQ specific Message id. I'm providing the correlation Id code for your reference and hope that you would be able to help me.
####################**********####################
/**Resolve the destination for replyto queue*/
final Destination replyDestination = getDestinationResolver().resolveDestinationName(ge tJmsTemplate().getConnectionFactory().
createConnection().createSession(false, Session.AUTO_ACKNOWLEDGE), replyQ, false);
final byte[] correlId = getCorrelationID();
getJmsTemplate().setDestinationResolver(getDestina tionResolver());
/**Send the message to the queue specified*/
getJmsTemplate().convertAndSend(destinationQueueNa me, message , new MessagePostProcessor(){
public Message postProcessMessage(Message message) throws JMSException {
message.setJMSReplyTo(replyDestination);
message.setJMSCorrelationIDAsBytes(correlId);
setMessage(message);
return message;
}
});/** setting the timeout limit to 10 sec */
getJmsTemplate().setReceiveTimeout(10000);/** selector = message id */
String selector = quot;JMSCorrelationID='quot; +correlId+quot;'quot;;/** read the reply message using the selector. */
Message response = getJmsTemplate().receiveSelected(replyDestination , selector);
//Message response = getJmsTemplate().receive(replyDestination); //this works fine.
####################**********####################Thanks in advance.
Sorry Guys, that was a silly thing to ask. I found that the in the reply message, a new correlation id is set irespective of presence of correlation id in the request message. So, correlation id in the request message was ignored. That's why I was getting the null response, whenever I use the selector. |
|