【问题标题】:IBM Websphere MQ displays javax.jms.TextMessage as <RFH >IBM Websphere MQ 将 javax.jms.TextMessage 显示为 <RFH >
【发布时间】:2015-12-20 23:47:28
【问题描述】:

我正在从 Java 代码向Websphere MQ Server 发送消息,当我在 MQ 服务器上读取相同的消息时,它显示为:

message<RFH >

下面是向MQ服务器发送消息的代码:

private void sendMessage() throws Exception {
        ConnectionFactory cf1 = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms/wmqCF");

        // Lookup Queue resource from JNDI
        Queue queue = (Queue) new InitialContext().lookup("java:comp/env/jms/wmqQ1");
        Connection con = cf1.createConnection();

        // start the connection to receive message
        con.start();

        // create a queue session to send a message
        Session sessionSender = con.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);

        MessageProducer send = sessionSender.createProducer(queue);

        TextMessage msg = sessionSender.createTextMessage("Liberty Sample Message");

        // send a sample message
        send.send(msg);

        if (con != null)
            con.close();
        System.out.println("Send Message Completed");
    }

预计显示为:Liberty Sample Message

任何想法,我在这里缺少什么?

谢谢。

【问题讨论】:

    标签: java queue jms ibm-mq websphere-liberty


    【解决方案1】:

    如果您使用另一个 JMS 程序检索消息,那么消息数据将是“Liberty Sample Message”。

    您正在混合使用 JMS 和非 JMS 程序类型。

    .lookup("java:comp/env/jms/wmqQ1");

    将“TARGCLIENT”属性设置为 MQ。即 TARGCLIENT(MQ)

    那么消息数据就没有RFH2头了。

    【讨论】:

    • 我的队列是javax.jms.Queue 类型而不是com.ibm.mq.jms.MQQueue,所以它没有设置TARGCLIENT 的选项。
    【解决方案2】:

    targetClient="MQ" 设置为 jmsQueue 的属性有效。

    下面是WLPserver.xml中的配置变化:

    <jmsQueue id="jms/queue1" jndiName="jms/wmqQ1">
        <properties.wmqJms baseQueueManagerName="QMA" baseQueueName="QUEUE1" targetClient="MQ"/>
    </jmsQueue>
    

    【讨论】:

      猜你喜欢
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-07
      • 1970-01-01
      • 2015-01-06
      • 2018-09-12
      • 1970-01-01
      相关资源
      最近更新 更多