向MQ发送消息时如何删除默认的Spring JMS Template头? [英] How to remove default Spring JMS Template headers when sending a message to an MQ?
问题描述
使用Java/Spring与WebSphere MQ交互并尝试向其发送消息,Spring会继续向其添加以下标头信息:
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
我将如何删除所有内容并仅发送我的有效载荷?可以在上面的代码段中将我的有效负载称为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;
}
});
}
推荐答案
弄清楚了.每当我们想从发送到WebSphere MQ的Spring JMS消息中删除标头时,请始终使用以下内容:
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);
}
这篇关于向MQ发送消息时如何删除默认的Spring JMS Template头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!