IBM Mq 消息头

发布于 2024-09-14 04:53:10 字数 1066 浏览 9 评论 0原文

我正在将消息发送到我无法控制的远程队列。

我发送一个 xml 文件作为消息,但是当应用程序读取消息时,它会得到一个消息头,就像

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

我不希望出现此消息头一样,我用于发送此消息的代码如下:

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

如何避免这种情况?

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

<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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

简单爱 2024-09-21 04:53:10

您似乎正在向非 jms 目标发送 jms 消息。消息在目的地是如何被消费的?它是否期待本机 MQ 消息?接收方不理解存储 JMS 标头属性的 MQRFH2 标头。

您应该配置目标以理解 jms,或者您可以执行类似以下操作来告诉 mq jms 您的接收者是非 jms 客户端。

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

It appears that you are sending a jms message to a non jms destination. How is the message being consumed on the destination? Is it expecting a native MQ message? The receiver is not understanding the MQRFH2 header that stores the JMS header properties.

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.

((com.ibm.mq.jms.MQQueue) queue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);
梦亿 2024-09-21 04:53:10

查看 JMS 对象的属性 如文档中所列。在管理对象上有一个名为 TARGCLIENT 的属性,应将其设置为“MQ”。尽管您可能无法控制受管理对象,但管理受管理对象的人员有责任正确设置此属性。如果目标不理解 RFH2 标头(WMQ v6 使用 RFH2 标头来保存 JMS 属性),则向该目标发送消息的任何 WMQ JMS 应用程序都必须设置该属性。

顺便说一句,您遇到此问题的事实往往表明使用消息的应用程序仍处于 v6 版本。请注意,WMQ v6.0 已于 2011 年 9 月终止。如果您现在在 QMgr 和客户端都切换到 v7,则可以通过队列本身的简单设置来管理它。旧版应用程序将理解这些消息,无论它们是否附加了 RFH2,并且无论旧版应用程序是否添加 RFH2 标头,客户端应用程序都会将响应视为 JMS 消息。立即迁移到 v7,为您自己节省开发此应用程序的大量麻烦,并且避免明年必须迁移到 v7。

可以下载 WMQ v7 客户端 此处

更新:WMQ V6 的生命周期终止已推迟至 2012 年 9 月。

Have a look at the properties for JMS objects as listed in the docs. On the administered object there is a property called TARGCLIENT which should be set to '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.

Incidentally, the fact that you are having this problem tends to indicate that the application consuming messages is still at 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. 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. 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.

WMQ v7 client downloads are available here

Update: End-of-life for WMQ V6 was pushed back to September 2012.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文