Accessing IBM MQ Message data from an application using IBM MQ classes for JMS
MQRFH2
header, any other IBM MQ headers, and the following message data.
Set the WMQ_MESSAGE_BODY property of the destination to WMQ_MESSAGE_BODY_MQ
, to receive all the message body data in the JMSBytesMessage.
If WMQ_MESSAGE_BODY is set to WMQ_MESSAGE_BODY_JMS
or WMQ_MESSAGE_BODY_UNSPECIFIED
, the message body is returned without the JMS MQRFH2
header, and the properties of the JMSBytesMessage reflect the properties set in the RFH2
.
Some applications cannot use the functions described in this topic. If an application is connected to an IBM MQ V6 queue manager, or if it has set PROVIDERVERSION to 6
, the functions are not available.
Sending a message
When sending messages the destination property, WMQ_MESSAGE_BODY, takes precedence over WMQ_TARGET_CLIENT.If WMQ_MESSAGE_BODY is set to WMQ_MESSAGE_BODY_JMS
, IBM MQ classes for JMS automatically generates an MQRFH2
header based on the settings of the JMSMessage properties and header fields.
If WMQ_MESSAGE_BODY is set to WMQ_MESSAGE_BODY_MQ
, no additional header is added to the message body
WMQ_MESSAGE_BODY_UNSPECIFIED
, IBM MQ classes for JMS sends an MQRFH2
header, unless WMQ_TARGET_CLIENT is set to WMQ_TARGET_DEST_MQ
. On receive, setting WMQ_TARGET_CLIENT to WMQ_TARGET_DEST_MQ
results in any MQRFH2
being removed from the message body.
MQRFH2
, whereas JMSStreamMessage, JMSMapMessage, and JMSObjectMessage do.
WMQ_MESSAGE_BODY_UNSPECIFIED
is the default setting for WMQ_MESSAGE_BODY, and WMQ_TARGET_DEST_JMS
is the default setting for WMQ_TARGET_CLIENT.
- JMS_IBM_Format or JMS_IBM_MQMD_Format: This property specifies the format of the IBM MQ header or application payload that starts the JMS message body if there is no preceding Websphere MQ header.
- JMS_IBM_Character_Set or JMS_IBM_MQMD_CodedCharSetId: This property specifies the CCSID of the IBM MQ header or application payload that starts the JMS message body if there is no preceding Websphere MQ header.
- JMS_IBM_Encoding or JMS_IBM_MQMD_Encoding: This property specifies the encoding of the IBM MQ header or application payload that starts the JMS message body if there is no preceding Websphere MQ header.
JMS_IBM_MQMD_*
properties override the corresponding JMS_IBM_*
properties, as long as the destination property WMQ_MQMD_WRITE_ENABLED is set to true
.
JMS_IBM_MQMD_*
and JMS_IBM_*
are significant:- The
JMS_IBM_MQMD_*
properties are specific to the IBM MQ JMS provider. - The
JMS_IBM_MQMD_*
properties are only set in theMQMD
.JMS_IBM_*
properties are set in theMQMD
only if the message does not have anMQRFH2
JMS header. Otherwise they are set in the JMSRFH2
header. - The
JMS_IBM_MQMD_*
properties have no affect on the encoding of text and numbers written into a JMSMessage.A receiving application is likely to assume the values of
MQMD.Encoding
andMQMD.CodedCharSetId
correspond to the encoding and character set of numbers and text in the message body. IfJMS_IBM_MQMD_*
properties are used, it is the responsibility of the sending application to make it so. The encoding and character set of numbers and text in the message body are set by theJMS_IBM_*
properties.The badly coded snippet in Figure 1 sends a message encoded in character set 1208, withMQMD.CodedCharSetId
set to 37.
MQRFH2
header being added.
Receiving a message
If WMQ_MESSAGE_BODY is set to WMQ_MESSAGE_BODY_JMS
, the inbound JMS message type and body are determined by the contents of the received Websphere MQ message. The message type and body are determined by fields in the MQRFH2
header, or in the MQMD
, if there is no MQRFH2
.
If WMQ_MESSAGE_BODY is set to WMQ_MESSAGE_BODY_MQ
, the inbound JMS message type is JMSBytesMessage. The JMS message body is the message data returned by the underlying MQGET API call. The length of message body is the length returned by the MQGET call. The character set and encoding of the data in the message body is determined by the CodedCharSetId and Encoding fields of the MQMD
. The format of the data in the message body is determined by the Format field of the MQMD
If WMQ_MESSAGE_BODY is set to WMQ_MESSAGE_BODY_UNSPECIFIED
, the default value, IBM MQ classes for JMS sets it to WMQ_MESSAGE_BODY_JMS
.
- JMS_IBM_Format or JMS_IBM_MQMD_Format: This property specifies the format of the IBM MQ header or application payload that starts the JMS message body if there is no preceding Websphere MQ header.
- JMS_IBM_Character_Set or JMS_IBM_MQMD_CodedCharSetId: This property specifies the CCSID of the IBM MQ header or application payload that starts the JMS message body if there is no preceding Websphere MQ header.
- JMS_IBM_Encoding or JMS_IBM_MQMD_Encoding: This property specifies the encoding of the IBM MQ header or application payload that starts the JMS message body if there is no preceding Websphere MQ header.
MQMD
, the message is a JMSBytesMessage.
((MQDestination)destination).setMessageBodyStyle
(WMQConstants.WMQ_MESSAGE_BODY_MQ);