简体   繁体   中英

How to remove default Spring JMS Template headers when sending a message to an MQ?

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

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

Sorry, i have the same problem. I removed the header RFH but now i have other problem. The message not send plain, any suggest? Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM