Skip to content
Advertisement

IBMMQ consumer application unable to consume TextMessage ( JMSCMQ1049: The character set ‘1208(UTF-8) Unmappable Action: REPORT)

I have a consumer application that uses IBMMQ to consume messages from the queue manager. I have no control over the publisher, only the consumer. Here is the part of the code for my consumer:

JavaScript

This code works fine and is able to retrieve the message as a TextMessage object for almost all of my queues except for one queue. When the application attempts to retrieve a message from this queue, I get this error:

JavaScript

After doing some debugging, I found that the error occurs when this code is executed: message.getText()

I believe that perhaps the message being put into the queue by the publisher contains some sort of special characters which the application is unable to handle. So I tried to see if I could consume the message for this specific queue using BytesMessage instead. Here is the code below:

JavaScript

However I am coming across this error:

JavaScript

From what I understand, the message cannot be casted from TextMessage to ByteMessage, which also means that the publisher sent the message as a TextMessage. If the publisher sent the message as a TextMessage, then why am I coming across this issue in the first place? I am a bit confused with all of this and would appreciate some guidance.


EDIT: I have ran amqsbcg as requested by @MoragHughson and here are the details to one of the messages:

JavaScript

It appears that the CodedCharSetId is 1208, which seems to be UTF-8. If that is the case, then TextMessages should work fine if i am not mistaken?

Advertisement

Answer

So, you have an interesting problem & I’ve been down this road before.

It is the opposite of what George Costanza from Friends would say: “it’s me not you”. In your case, it is the sender and not you.

There are 3 important pieces of information from the amqsbcg dump:

JavaScript

(1) That message is not a JMS (aka MQRFH2) message but JMS/MQ layer will turn it into a JMS message for the application.

  • If the MQMD Format field is set to “MQSTR ” then the MQ/JMS layer will create a TextMessage.
  • If the MQMD Format field is set to ” ” (all blank) then the MQ/JMS layer will create a BytesMessage.

(2) Since the incoming message’s MQMD Format field is set to “MQSTR “, the JMS/MQ layer will attempt to convert it from the CCSID of 1208 to the CCSID of your JVM. The problem comes from the fact that you have non-alphanumeric data in your message. Lots of binary zeroes in the first 12 bytes.

You have 2 options:

(1) Ask the sender to stop including non-alphanumeric data in the message.

(2) If the non-alphanumeric data is important then tell the sender to set the message’s MQMD Format field to ” ” (all blank). Then when you get the message, you simply cast it as BytesMessage.

Most likely some junior programmer copied code from StackOverflow or somewhere else and used it without understanding what the code did.

Note to future MQ developers/programmers: If your message payload has non-alphanumeric data then never ever set the message’s MQMD Format field to “MQSTR “.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement