【问题标题】:Mule JMS message truncated - IBM MQMule JMS 消息被截断 - IBM MQ
【发布时间】:2018-08-12 13:51:51
【问题描述】:

我有一个问题,我的 jms 消息没有完全发送到队列并被截断,队列中只设置了 100 个字符。 这是我的配置:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:util="http://www.springframework.org/schema/util"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:task="http://www.springframework.org/schema/task"
xmlns:script="http://www.mulesoft.org/schema/mule/scripting"

xsi:schemaLocation="
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.4/mule.xsd
      hhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
      http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.4/mule-http.xsd
      http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.4/mule-jms.xsd
      http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.4/mule-vm.xsd
      http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
      http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
      http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.3/mule-scripting.xsd
      http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd">


<spring:bean id="MQConnectionFactory"  class="com.ibm.mq.jms.MQQueueConnectionFactory">
   <spring:property name="transportType" value="1" />
   <spring:property name="hostName" value="222.222.100.58"/>
   <spring:property name="port" value="1414"/>           
   <spring:property name="queueManager" value="ESBDEVBKRQM"/>
</spring:bean>

<jms:connector name="WebsphereMQConnector"
    connectionFactory-ref="MQConnectionFactory" 
    username="Administrator" password="*****"
    numberOfConsumers="200" />


<flow name="test-webSphere-flow">
    <http:inbound-endpoint address="http://localhost:8081/test/in/websphere3" method="POST"/>
    <object-to-string-transformer />
    <jms:outbound-endpoint queue="ACCT_Q_REQ" connector-ref="WebsphereMQConnector"/>
</flow>

</mule>

为了确保问题不是来自 wepshpere mq 端,我使用带有 ibm API 的 java 代码来发送消息,并且它已完全发送

package jms;

import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Queue;

import javax.jms.Session;
import javax.jms.TextMessage;

import com.ibm.mq.jms.MQQueueConnectionFactory;


public class TestJMS {

    void send() {
        String destinationName = "ACCT_Q_REQ";

        MessageProducer producer = null;
        Connection connection = null;
        Session session = null;

        try {

            MQQueueConnectionFactory MQQueueConnectionFactory = new MQQueueConnectionFactory();
            MQQueueConnectionFactory.setTransportType(1);
            MQQueueConnectionFactory.setHostName("222.222.100.58");
            MQQueueConnectionFactory.setPort(1414);
            MQQueueConnectionFactory.setQueueManager("ESBDEVBKRQM");

            connection = MQQueueConnectionFactory.createConnection("Administrator", "******");

            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            Queue source = session.createQueue(destinationName);
            producer = session.createProducer(source);
            connection.start();

            String text = ".....";
            TextMessage objectMessage = session.createTextMessage();
            objectMessage.setText(text);
            producer.send(objectMessage);

        } catch (JMSException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new TestJMS().send();
    }

}

这可能是什么问题?

【问题讨论】:

  • 您是否偶然使用 MQ Explorer 查看消息?因为它只会显示消息的前 100 个字节(硬编码限制)。您需要像 MQ Visual Edit 这样的 MQ 工具来查看/编辑整个消息。
  • @Roger 是的,我正在使用 MQ 资源管理器。如果使用 java API 发送消息,消息将完全显示。
  • 错别字,应该是 1000 而不是 100。

标签: jms ibm-mq mule-esb


【解决方案1】:

您应该检查所有 MQ 相关的最大消息大小限制:

  1. MQ 连接的 MaxMsgLength - 这是 MQQueueConnectionFactory 的一部分
  2. 队列管理器最大消息长度,MAXMSGL
  3. 队列的 MQIA_MAX_MSG_LENGTH
  4. 如果您通过 MQ 通道接收消息,即使是通道的 MAXMSGL

以上所有内容都必须设置为高于 1000 的值才能正常工作...

【讨论】:

  • 这可能不是问题所在。如果消息大于 1000 不截断它,则会导致错误。
猜你喜欢
  • 2011-01-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多