Issue
Using Java/Spring to interact with a WebSphere MQ and trying to send a message to it, Spring keeps adding the following header information to it:
RFH Ì ¸MQSTR ¸ <mcd><Msd>jms_text</Msd></mcd> <jms><Dst>queue:///MY.QUEUE.INFORMATION.TEST</Dst><Rto>queue:///MY.QUEUE.INFORMATION.TEST</Rto><Tms>123456789</Tms><Dlv>2</Dlv></jms>BEGINNING_OF_MY_PAYLOAD
How would I remove everything and only send my payload? One could refer to my payload in the snippet above as BEGINNING_OF_MY_PAYLOAD
.
Here's the function I'm using:
public void sendMessage(final String text) {
this.jmsTemplate.send(new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
Message message = session.createTextMessage(text);
destination = session.createQueue("MY.QUEUE.INFORMATION.TEST");
springJmsConsumer.setDestination(destination);
message.setJMSReplyTo(destination);
return message;
}
});
}
Solution
Figured it out. Anytime we want to remove headers from our Spring JMS message being sent out to a WebSphere MQ, always use the following:
this.jmsTemplate.convertAndSend("queue:///YOUR.QUEUE.NAME.HERE?targetClient=1", text);
So now my function looks like:
public void send(String text) {
this.jmsTemplate.convertAndSend("queue:///MY.QUEUE.INFORMATION.TEST?targetClient=1", text);
}
Answered By - abhi
Answer Checked By - Willingham (JavaFixing Volunteer)