Issue
jmsTemplate.sendAndReceive("Queue2", session -> {
TextMessage msg = session.createTextMessage();
msg.setText(message);
msg.setJMSReplyTo(config.getReplyQ()); //Not updated but auto generated queue updated
msg.setJMSCorrelationID("asd_123584_lkj"); //Updated in Destination Queue
msg.setJMSType("MQSTR");
System.out.println("Message : "+msg);
return msg;
});
public Destination getReplyQ() throws JMSException {
MQQueue replyToQ = new MQQueue(queueManager, replyQueue);
Destination replyTo = (Destination) replyToQ;
return replyTo;
}
I read some articles that says using JMS will update the RFH but not MQMD and this Reply-To Queue is part of MQMD and I didn't find the right class to update the MQMD header and send the message to MQ and update the reply-to queue.
Solution
jmsTemplate.send(config.getQ(), session -> {
TextMessage msg = session.createTextMessage();
msg.setText(message);
msg.setJMSReplyTo(config.getReplyQ());
msg.setJMSCorrelationID("asd_123584_lkj");
System.out.println("Message : " + msg);
return msg;
});
Above method will set the JMSReplyTo.
And to ignore the RFH2 header setTargetClient(WMQConstants.WMQ_CLIENT_NONJMS_MQ) can be used like below:
public Destination getQ() throws JMSException {
MQQueue replyToQ = new MQQueue(queueManager, queues);
replyToQ.setTargetClient(WMQConstants.WMQ_CLIENT_NONJMS_MQ);
Destination rt = (Destination) replyToQ;
return rt;
}
Answered By - Rohan Saxena
Answer Checked By - Marilyn (JavaFixing Volunteer)