简体   繁体   English

IBM Mq消息头

[英]IBM Mq Message Header

I am sending messages to a remote queue, to which I have no control. 我正在向远程队列发送消息,我无法控制。

I send a xml file as message but when the application reads the message it gets a message header like 我发送一个xml文件作为消息,但当应用程序读取消息时,它会获得一个消息标题

<mcd><Msd>jms_text</Msd></mcd>  \0\0\0l<jms><Dst>queue:///TEST</Dst><Tms>1281475843707</Tms><Cid></Cid><Dlv>1</Dlv></jms>

i don't want this message header to be present and my code for sending this message is as follows: 我不希望这个消息头存在,我发送此消息的代码如下:

Properties props = new Properties();
    props.setProperty("java.naming.factory.initial",this.initialFactory);
    props.setProperty("java.naming.provider.url", url);

    Context context = new InitialContext(props);

    QueueConnectionFactory qcf = (QueueConnectionFactory) context.lookup(this.context);
    qConn = qcf.createQueueConnection();
    queue = (Queue)context.lookup(name);
    qSession = qConn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
    qConn.start();
            QueueSender send = qSession.createSender(queue);
     String text = "My xml file";
     TextMessage tm = qSession.createTextMessage(text);
     send.send(tm);
     send.close();

How do I avoid this ? 我该如何避免这种情况?

It appears that you are sending a jms message to a non jms destination. 您似乎正在向非jms目的地发送jms消息。 How is the message being consumed on the destination? 消息如何在目的地上消耗? Is it expecting a native MQ message? 是否期望本机MQ消息? The receiver is not understanding the MQRFH2 header that stores the JMS header properties. 接收方不了解存储JMS头属性的MQRFH2头。

You should either configure the destination to understand jms or your can do something like the following to tell the mq jms that your receiver is a non-jms client. 您应该配置目标以了解jms,或者您可以执行以下操作来告诉mq jms您的接收器是非jms客户端。

((com.ibm.mq.jms.MQQueue) queue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);

Have a look at the properties for JMS objects as listed in the docs . 查看文档中列出的 JMS对象的属性。 On the administered object there is a property called TARGCLIENT which should be set to 'MQ'. 在被管理对象上有一个名为TARGCLIENT的属性,应该设置为'MQ'。 Although you may have no control over the administered object, it is the responsibility of the person who administers the managed objects to set this property correctly. 尽管您可能无法控制受管理对象,但管理受管对象的人员有责任正确设置此属性。 If the destination does not understand the RFH2 headers (which WMQ v6 uses to hold JMS properties) then any WMQ JMS applications which send messages to that destination must have that property set. 如果目标不理解RFH2标头(WMQ v6用于保存JMS属性),那么向该目标发送消息的任何WMQ JMS应用程序都必须设置该属性。

Incidentally, the fact that you are having this problem tends to indicate that the application consuming messages is still at v6. 顺便提一下,您遇到此问题的事实往往表明应用程序使用消息仍处于v6。 Please be aware that v6.0 of WMQ is end-of-life as of Sept 2011. If you switch to v7 now at both the QMgr and the client side, you can manage this with simple settings on the queue itself. 请注意,WMQ的v6.0截至2011年9月已停止使用。如果您现在在QMgr和客户端都切换到v7,则可以通过队列本身的简单设置进行管理。 The legacy app will understand the messages regardless of whether they have an RFH2 attached and the client app will see the responses as JMS messages regardless of whether the legacy app adds RFH2 headers. 遗留应用程序将理解消息,无论它们是否附加了RFH2,并且客户端应用程序将响应视为JMS消息,无论旧应用程序是否添加RFH2标头。 Move to v7 now, save your self a whole lot of trouble developing this app and also avoid having to migrate to v7 next year. 现在转到v7,保存自己在开发这个应用程序时遇到很多麻烦,同时避免明年迁移到v7。

WMQ v7 client downloads are available here WMQ v7客户端下载可在此处获得

Update : End-of-life for WMQ V6 was pushed back to September 2012. 更新 :WMQ V6的寿命终止已推迟至2012年9月。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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