Search code examples
javaspring-bootjmsibm-mqjmstemplate

Reply-To Queue is not updating in IBM MQ while putting message type as request


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;
    }

IBM MQ message

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.

    Here the definition of sendAndReceive is present which stated that "a temporary queue is created as part of this operation and is set in the JMSReplyTO header of the message"

    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;
        }