Application data conversion
When necessary, MCAs convert the message descriptor and header data into the required character set and encoding. Either end of the link (that is, the local MCA or the remote MCA) can do the conversion.
When an application puts messages on a queue, the local queue manager adds control information to the message descriptors to facilitate the control of the messages when they are processed by queue managers and MCAs. Depending on the environment, the message header data fields are created in the character set and encoding of the local system.
When you move messages between systems, you sometimes need to convert the application data into the character set and encoding required by the receiving system. This can be done either from within application programs on the receiving system or by the MCAs on the sending system. If data conversion is supported on the receiving system, use application programs to convert the application data, rather than depending on the conversion having already occurred at the sending system.
Application data is converted within an application program when you specify the MQGMO_CONVERT option in the Options field of the MQGMO structure passed to an MQGET call, and all the following are true:
- The CodedCharSetId or Encoding fields set in the MQMD structure associated with the message on the queue differ from the CodedCharSetId or Encoding fields set in the MQMD structure specified on the MQGET call.
- The Format field in the MQMD structure associated with the message is not MQFMT_NONE.
- The BufferLength specified on the MQGET call is not zero.
- The message data length is not zero.
- The queue manager supports conversion between the CodedCharSetId and Encoding fields specified in the MQMD structures associated with the message and the MQGET call. See the Application Programming Reference for details of the coded character set identifiers and machine encodings supported.
- The queue manager supports conversion of the message format. If the Format field of the MQMD structure associated with the message is one of the built-in formats, the queue manager can convert the message. If the Format is not one of the built-in formats, you need to write a data-conversion exit to convert the message.
If the sending MCA is to convert the data, specify the CONVERT(YES) keyword on the definition of each sender or server channel for which conversion is required. If the data conversion fails, the message is sent to the DLQ at the sending queue manager and the Feedback field of the MQDLH structure indicates the reason. If the message cannot be put on the DLQ, the channel closes and the unconverted message remains on the transmission queue. Data conversion within applications rather than at sending MCAs avoids this situation.
As a general rule, data in the message that is described as character data by the built-in format or data-conversion exit is converted from the coded character set used by the message to that requested, and numeric fields are converted to the encoding requested.
For further details of the conversion processing conventions used when converting the built-in formats, and for information about writing your own data-conversion exits, see Writing data-conversion exits. See also the Application Programming Reference for information about the language support tables and about the supported machine encodings.
Parent topic:
Writing a WebSphere MQ application
fg12810_