简体   繁体   English

Java消息选择器,用于从Websphere MQ获取组消息

[英]Java Message selector for getting group Message from websphere mq

I'm trying to Receive a Group Message from a websphere mq 8 Queue Manager within a Java mdb. 我正在尝试从Java mdb中的websphere mq 8队列管理器接收组消息。 When getting the LastMessageInGroup I Receive a jmsxgroupid like 'ID:45fdea5589' ( getStringProperty ) from the message. 当获取LastMessageInGroup我从消息中收到一个jmsxgroupid例如'ID:45fdea5589'getStringProperty )。 When I'm trying to get the other Messages of this Group I'm Using a messageconsumer with a messageselector where I'm Adding exactly the jmsxgroupid with an additional jmsxsequence from above, but When calling the method receiveNoWait from the messageConsumer I receive a Null BytesMessage 当我试图让这个小组的其他消息,我使用messageconsumermessageselector在那里我添加的究竟jmsxgroupid一个额外jmsxsequence从上面,但是当调用方法receiveNoWaitmessageConsumer我收到一个Null BytesMessage

The Funny thing is, when the groupid is Human readable String like ' 20151019 ' it Works. 有趣的是,当groupid是类似于“ 20151019 ”的人类可读字符串时,它起作用

So this is part of the Code. 因此,这是《守则》的一部分。
We receive lastMessage in the method onMessage of our MDB. 我们在MDB的onMessage方法中收到lastMessage。
We read the JMSXGroupID of this lastMessage with the method 我们使用方法读取此lastMessage的JMSXGroupID
String gid = lastMessage.getStringProperty("JMSXGroupID"). 字符串gid = lastMessage.getStringProperty(“ JMSXGroupID”)。 Then we build a selector to get the other message(s) of this group like this: 然后,我们构建一个选择器以获取该组中的其他消息,如下所示:
String strSelector = "JMSXGroupID='" + gid + "' AND JMSXGroupSeq=1"; 字符串strSelector =“ JMSXGroupID ='” + gid +“'AND JMSXGroupSeq = 1”;
consumer = session.createConsumer(destIncoming, strSelector); 消费者= session.createConsumer(destIncoming,strSelector);
bmCurrentMessage = (BytesMessage) consumer.receiveNoWait(); bmCurrentMessage =(BytesMessage)Consumer.receiveNoWait();
When the gid is like 'ID:8d74b544d5862f32156cbfe845077c02d18ba33ac51c06aa' we receive a null BytesMessage! 当gid类似于'ID:8d74b544d5862f32156cbfe845077c02d18ba33ac51c06aa'时,我们会收到一个空的BytesMessage! The mq acts like the queue is empty. mq的行为就像队列是空的。
When the gid is like '20151015081515' we receive the other messages of the group message! 当gid类似于“ 20151015081515”时,我们会收到组消息中的其他消息!

Any Tips what I Should do different? 任何提示我应该做些什么?

Thanks so far for Reading Thomas 到目前为止,感谢您阅读托马斯

Well after long time of analysing together with MQ experts from IBM we had to install a fix package offered by IBM to fix this problem. 在与IBM的MQ专家一起进行了长时间的分析之后,我们不得不安装IBM提供的修订包来解决此问题。 So there was obviously no problem with our code but some problem inside the IBM code of the MQ Server 8 we were using. 因此,我们的代码显然没有问题,但是我们正在使用的MQ Server 8的IBM代码内部存在一些问题。

Now the problem is solved by installing the latest fix of IBM. 现在,通过安装IBM的最新修补程序解决了问题。

Thanks to all for reading and thinking about my problem! 感谢所有阅读和思考我的问题!

Remember that the GroupID, just like the MessageID and CorrelationID, is not a string field. 请记住,GroupID就像MessageID和CorrelationID一样,不是字符串字段。 You say it works when it is a human readable string, which implies the times it is failing for you is when the GroupID is not human readable. 您说它在人类可读的字符串时有效,这意味着当GroupID不可读时,它对您来说失败的时间就很大。 This suggests you are not requesting the correct GroupID for the subsequent messages in the group because of the string processing you have done on it. 这表明由于对字符串进行了字符串处理,因此您没有为该组中的后续消息请求正确的GroupID。 Treat it as a byte string and not a character string. 将其视为字节字符串而不是字符串。

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

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