Reputation: 24354
I am using Websphere MQ and reading messages from the queue using Spring integration and a jms adapter.
When I manually add messages to the queue the application is reading them and reading the data as a String
and everything is fine.
However, when an external party is adding messages to the queue the application is reading them as a byte array and then throwing this exception:
Caused by: java.lang.ClassCastException: [B cannot be cast to java.lang.String
The messages look the same to me in MQExplorer.
Although I have noticed a Format column, where the messages that are being processed as Strings have the value MQSTR
and the message being processed as a Byte[] has nothing in there. Could this be related? If so any ideas how to set the "format" of the message?
Does anybody know what determines the payload content type of a message, that way I may be able to recreate the issue at least?
Upvotes: 1
Views: 11549
Reputation: 89
On native MQ message sender side, set the mqmd["Format"] = 'MQSTR' will make sure the message is sent in jms_text format, otherwise by default it's in bytes format.
I got it working in Python2.7 with Pymqi.
Upvotes: 1
Reputation: 1678
I've encountered this kind of situation before. The external party may not be using JMS, but may be using the MQI or the Websphere MQ classes for Java.
This means that you may be receiving the messages as ByteMessages.
This article explains the conversion of MQ messages to JMS messages.
I would talk to the external party and ask them how they are sending their messages. They may have to give you details of the MQMD properties they are setting. You may have to retrieve these in your MessageListener.
Upvotes: 4