MQ

MQ

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Understanding and resolving MQRC_FORMAT_ERROR when using amqsget with MQTT messages

By SAVITHA JOSHI posted Wed July 17, 2024 12:22 AM

  

I came across this query and thought it might be helpful to share the solution for others who might face the same problem with IBM MQ and MQTT.

When working with IBM MQ and MQTT, you might encounter the MQRC 2110 error i.e MQRC_FORMAT_ERROR error code while trying to retrieve messages using an MQ application like amqsget. This issue typically arises when an MQTT client application publishes a message to a topic, and the MQTT service converts this publication into an IBM MQ message in RFH2 format.

The root cause of this problem lies in how the format field on the RFH2 message is set. By default, it is set to MQFMT_NONE, which means no conversion is applied to the message content. Consequently, when you attempt to retrieve the message using amqsget with the MQGMO_CONVERT option, you get the MQRC_FORMAT_ERROR because MQGMO_CONVERT expects a specific format to apply conversion rules, which are not available for MQFMT_NONE.

Why This Happens

Message Publishing: When an MQTT client publishes a message on a topic, the MQTT service converts this message into an IBM MQ message in RFH2 format.

Format Field Setting: The format field on the RFH2 message is set to MQFMT_NONE, as detailed in the IBM documentation.

Message Retrieval: When you use the amqsget application with the MQGMO_CONVERT option to get the message, the application tries to convert the message format. Since the format is set to MQFMT_NONE, no conversion rules are applied, leading to the MQRC_FORMAT_ERROR.

Expected Behaviour and Solution

This behaviour is expected. The message remains in the same format as it was put by the MQTT client application. To handle this correctly:

  • Avoid Using MQGMO_CONVERT: When retrieving MQTT messages that have been converted to IBM MQ messages with MQFMT_NONE, you should not set the MQGMO_CONVERT option in your MQ get application.
  • Handle MQRC_FORMAT_ERROR Gracefully: Alternatively, you can tolerate the MQRC_FORMAT_ERROR reason code and interpret the message appropriately without conversion.

By following these guidelines, you can ensure smooth message retrieval without encountering format errors.

For further details, you can refer to the IBM documentation on the integration of MQ Telemetry and Queue Managers here. Also, if you're interested in knowing more about MQ conversion refer here.

2 comments
22 views

Permalink

Comments

Fri August 02, 2024 02:40 AM

https://www.ibm.com/docs/en/ibm-mq/9.3?topic=exit-conversion-processing

We are seeing the same as mentioned in Second point in above link i.e

If the MQGMO_CONVERT option is used and if the character set or encoding of the message data differs from the corresponding value in the MsgDesc parameter, and there is data to be converted and Format field in the control information in the message has the value MQFMT_NONE, then we see this issue.

Thu August 01, 2024 07:08 PM

There must be more to it than you describe. A format field set to MQFMT_NONE does not in itself cause MQRC_FORMAT_ERROR. What else is going on here?