Queue manager data conversion
Queue manager data conversion has always been available to non-JMS applications receiving messages from JMS clients. JMS clients receiving messages also use queue manager data conversion, which is optional.
The queue manager can convert character and numeric data in message data using the values of
CodedCharacterSetId, Encoding, and Format set for
the message data. For non-JMS applications the
conversion capability has always been available by setting the GetMessageOption,
GMO_CONVERT.
The queue manager is able to convert messages that are sent to JMS clients. Queue manager conversion is controlled by setting
the destination property, WMQ_RECEIVE_CONVERSION, to
WMQ_RECEIVE_CONVERSION_QMGR, or WMQ_RECEIVE_CONVERSION_CLIENT_MSG.
The application can change the destination setting:
((MQDestination)destination).setIntProperty(
WMQConstants.WMQ_RECEIVE_CONVERSION,
WMQConstants.WMQ_RECEIVE_CONVERSION_QMGR);
Or,
((MQDestination)destination).setReceiveConversion
(WMQConstants.WMQ_RECEIVE_CONVERSION_QMGR);
Queue manager data conversion for a JMS client takes place when the client calls a consumer.receive method. Text data is transformed into UTF-8 (1208) by default. Subsequent read and get methods decode text in the received data from UTF-8, creating Java text primitives in their internal Unicode encoding. UTF-8 is not the only target character set from queue manager data conversion. You can choose a different CCSID by setting the WMQ_RECEIVE_CCSID destination property.
((MQDestination)destination).setIntProperty
(WMQConstants.WMQ_RECEIVE_CCSID, 437);
Or,
((MQDestination)destination).setReceiveCCSID(437);
The reason for changing WMQ_RECEIVE_CCSID is specialized; the chosen CCSID makes no difference to the text objects created in the JVM. However, some JVMs, on some platforms, might not be able to handle conversion from the CCSID of text in the message into Unicode. The option gives you a choice of CCSID for any text delivered to the client in the message. Some JMS client platforms have had problems with message text being delivered in UTF-8.
The JMS code is equivalent to the bold text in the C code in Figure 3,
gmo.Options = MQGMO_WAIT /* wait for new messages */
| MQGMO_NO_SYNCPOINT /* no transaction */
| MQGMO_CONVERT; /* convert if necessary */
while (CompCode != MQCC_FAILED) {
buflen = sizeof(buffer) - 1; /* buffer size available for GET */
memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId));
memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId));
md.Encoding = MQENC_NATIVE;
md.CodedCharSetId = MQCCSI_Q_MGR;
MQGET(Hcon, /* connection handle */
Hobj, /* object handle */
&md, /* message descriptor */
&gmo, /* get message options */
buflen, /* buffer length */
buffer, /* message buffer */
&messlen, /* message length */
&CompCode, /* completion code */
&Reason); /* reason code */
Queue manager conversion is only performed on the message data that has a known IBM® MQ format. MQSTR, or MQCIH are examples of known formats that are predefined. A known format can also be user-defined format, as long as you have supplied a data-conversion exit.
Messages constructed as JMSTextMessage, JMSMapMessage and JMSStreamMessage, have a MQSTR format, and can be converted by the queue manager.