com.ibm.mq.MQException

发布于 2024-09-24 18:05:24 字数 1136 浏览 3 评论 0原文

已经被这个问题困扰了几个小时了,有人有什么想法吗?

java.lang.NoSuchMethodError: com.ibm.mq.MQException.(Ljava/lang/String;Ljava/lang/String;II)V 在 com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:223) 在 com.ibm.msg.client.wmq.internal.WMQMessageConsumer.checkJmqiCallSuccess(WMQMessageConsumer.java:123) 在 com.ibm.msg.client.wmq.internal.WMQConsumerShadow.getMsg(WMQConsumerShadow.java:1198) 在 com.ibm.msg.client.wmq.internal.WMQSyncConsumerShadow.receiveInternal(WMQSyncConsumerShadow.java:233) 在 com.ibm.msg.client.wmq.internal.WMQConsumerShadow.receive(WMQConsumerShadow.java:922) 在 com.ibm.msg.client.wmq.internal.WMQMessageConsumer.receive(WMQMessageConsumer.java:450) 在 com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl.receiveInboundMessage(JmsMessageConsumerImpl.java:742) 在 com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl.receive(JmsMessageConsumerImpl.java:423) 在 com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:258)

当我使用 MQ 本机库放置消息并使用 JMS API 读取它们时,出现此错误。 jms 读取失败,抛出上述异常。我也在使用 jms Selector,这似乎是导致问题的原因。没有选择器一切正常。 TIA。

Have been stuck with this problem for a few hours now, anyone any ideas?

java.lang.NoSuchMethodError: com.ibm.mq.MQException.(Ljava/lang/String;Ljava/lang/String;II)V
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:223)
at com.ibm.msg.client.wmq.internal.WMQMessageConsumer.checkJmqiCallSuccess(WMQMessageConsumer.java:123)
at com.ibm.msg.client.wmq.internal.WMQConsumerShadow.getMsg(WMQConsumerShadow.java:1198)
at com.ibm.msg.client.wmq.internal.WMQSyncConsumerShadow.receiveInternal(WMQSyncConsumerShadow.java:233)
at com.ibm.msg.client.wmq.internal.WMQConsumerShadow.receive(WMQConsumerShadow.java:922)
at com.ibm.msg.client.wmq.internal.WMQMessageConsumer.receive(WMQMessageConsumer.java:450)
at com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl.receiveInboundMessage(JmsMessageConsumerImpl.java:742)
at com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl.receive(JmsMessageConsumerImpl.java:423)
at com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:258)

Am getting this error when i put the message using MQ native libraries and i read them using JMS API's. The jms read fails throwing the exception above. I am also using jms Selector which seems to be causing the problem. with out the selector everything works fine. TIA.

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

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

发布评论

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

评论(2

撩人痒 2024-10-01 18:05:24

最后我能够解决这个问题,这一切都与选择器的创建方式有关。不同之处在于 MQ API 将相关 ID 作为字节数组,而 JMS 将其作为字符串。因此,选择器无法选择消息并抛出已发布的错误。该错误根本不适合调试,因此必须进行大量的试验和错误。不管怎样,现在这有效了,所以我很高兴。下面是我为此必须做的代码更改:

//字符串选择器 = "JMSCorrelationID = '" + corleationID + "'";更改前

        StringBuffer fBuf = new StringBuffer("JMSCorrelationID = 'ID:");
        byte[] correlBytes = corleationID.getBytes();
        for(int i=0; i<24; i++) {
          if (i>=correlBytes.length) {
            fBuf.append("00");
          } else {
            byte b = correlBytes[i];
            String hexStr = Integer.toHexString(b);
            // -ve values produce 8 char results
            if (hexStr.length()>2) hexStr = hexStr.substring(hexStr.length()-2);
            // small values produce 1 char results
            if (hexStr.length()<2) fBuf.append("0");
            fBuf.append(hexStr);
          }
        }
        fBuf.append("'");
        String filter = fBuf.toString();
        System.out.println("creating receiver with filter: "+filter);
        QueueReceiver queueReceiver = queueSession.createReceiver(inQueue,filter);

// QueueReceiverqueueReceiver =queueSession.createReceiver(inQueue, 选择器);

参考了IBM文档中的代码。

Finally i was able to resolve this, it all had to do with how the selector is created. The difference was that MQ API's have correlation id as bytes array where as JMS takes it as a string. Due to this the Selector was unable to select the message and was throwing the posted error. The error is not at all debug friendly hence had to do a lot of trial and error. Anyways now this works so i am glad. Below is the code change i had to do for this:

//String selector = "JMSCorrelationID = '" + corleationID + "'"; before change

        StringBuffer fBuf = new StringBuffer("JMSCorrelationID = 'ID:");
        byte[] correlBytes = corleationID.getBytes();
        for(int i=0; i<24; i++) {
          if (i>=correlBytes.length) {
            fBuf.append("00");
          } else {
            byte b = correlBytes[i];
            String hexStr = Integer.toHexString(b);
            // -ve values produce 8 char results
            if (hexStr.length()>2) hexStr = hexStr.substring(hexStr.length()-2);
            // small values produce 1 char results
            if (hexStr.length()<2) fBuf.append("0");
            fBuf.append(hexStr);
          }
        }
        fBuf.append("'");
        String filter = fBuf.toString();
        System.out.println("creating receiver with filter: "+filter);
        QueueReceiver queueReceiver = queueSession.createReceiver(inQueue,filter);

// QueueReceiver queueReceiver = queueSession.createReceiver(inQueue, selector);

Referred the code from IBM docs.

热血少△年 2024-10-01 18:05:24

您的 MQ 库版本错误。尝试针对最新版本运行您的代码。

You've got wrong version of MQ libraries. Try to run your code against the newest versions.

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