MQ

 View Only

Understanding and resolving MQRC_FORMAT_ERROR when using amqsget with MQTT messages

By SAVITHA JOSHI posted 10 days ago

  

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.

0 comments
16 views

Permalink