JMS message conversion
Message data conversion in JMS is performed when sending and receiving messages. WebSphere® MQ performs most data conversion automatically. It converts text and numeric data when transferring a message between JMS applications. Text is converted when exchanging a JMSTextMessage between a JMS application and a WebSphere MQ application.
- Transferring non-text messages between a WebSphere MQ application and a JMS application.
- Exchanging text data in byte format.
- Converting the text in your application.
JMS message data
Data conversion is necessary
to exchange text and numeric data between applications, even between
two JMS applications. The internal representation of text and numbers
must be encoded so they can be transferred in a message. Encoding
forces a decision about how numbers and text are represented.
WebSphere MQ manages the encoding
of text and numbers in JMS messages, except for JMSObjectMessage,
see JMSObjectMessage. It uses three
message attributes. The three attributes are CodedCharacterSetId
, Encoding
,
and Format
.
These three message attributes
are normally stored in the JMS header, MQRFH2
, fields
of a JMS message. If the message type is an MQ
, rather
than JMS
type of message, the attributes are stored
in the message descriptor, MQMD
. The attributes are
used to convert the JMS message data. JMS message data is transferred
in the message data part of a WebSphere MQ message.
JMS message properties
JMS message properties,
such as JMS_IBM_CHARACTER_SET
, are exchanged in the MQRFH2
header
part of a JMS message, unless the message has been sent without an MQRFH2
.
Only JMSTextMessage
and JMSBytesMessage
can
be sent without an MQRFH2
. If a JMS property is stored
as a WebSphere MQ message property in the message descriptor, MQMD
,
it is converted as part of the MQMD
conversion. If
a JMS property is stored in the MQRFH2
, it is stored
in the character set specified by MQRFH2.NameValueCCSID
.
When a message is sent or received, message properties are converted
to and from their internal representation in the JVM. The conversion
is to and from the character set of the message descriptor or MQRFH2.NameValueCCSID
.
Numeric data is converted to text.
JMS message conversion
The following topics contain examples and tasks that are useful if you plan to exchange more complex messages that require conversion.