JMS message conversion

Message data conversion in JMS is performed when sending and receiving messages. IBM 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 an IBM MQ application.

If we are planning to do more complex message exchanges, the following topics are of interest you. Complex message exchanges include:

  • Transfer non-text messages between an IBM MQ application and a JMS application.
  • Exchanging text data in byte format.
  • Convert the text in the 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. IBM 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 an IBM 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 an IBM 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 we plan to exchange more complex messages that require conversion.

  • JMS message conversion approaches
    A number of data conversion approaches are open to JMS application designers. These approaches are not exclusive; some applications are likely to use a combination of these approaches. If the application is exchanging only text or is exchanging messages only with other JMS applications, we do not normally consider data conversion. Data conversion is performed automatically for you, by IBM MQ.
  • JMS message types and conversion
    The choice of message type affects the approach to message conversion. The interaction of message conversion and message type is described for the JMS message types, JMSObjectMessage, JMSTextMessage, JMSMapMessage, JMSStreamMessage, and JMSBytesMessage.
  • JMS client message conversion and encoding
    The methods we use to do JMS client message conversion and encoding are listed, with code examples of each type of conversion.
  • Queue manager data conversion
    Queue manager data conversion has always been available to non-JMS applications receiving messages from JMS clients. Since V7.0, JMS clients receiving messages also use queue manager data conversion. From 7.0.1.5, or 7.0.1.4 with APAR IC72897, queue manager data conversion is optional.
  • Exchanging a formatted record with a non-JMS application
    Follow the steps suggested in this task to design and build a data conversion exit, and a JMS client application that can exchange messages with a non-JMS application using JMSBytesMessage. The exchange of a formatted message with a non-JMS application can take place with or without calling a data conversion exit.

Parent topic: JMS messages