WebSphere Message Service Clients for C/C++ and .NET, Version 1.2 Operating Systems: Linux, Windows

The body of an XMS message

The body of a message contains application data. However, a message can have no body, and comprise only the header fields and properties.

XMS supports five types of message body:
Bytes
The body contains a stream of bytes. A message with this type of body is called a bytes message. The BytesMessage class for C or C++ and IBytesMessage interface for .NET contain the methods to process the body of a bytes message.
Map
The body contains a set of name-value pairs, where each value has an associated data type. A message with this type of body is called a map message. The MapMessage class for C or C++ and IMapMessage interface for .NET contain the methods to process the body of a map message.
Object
The body contains a serialized Java or .NET object. A message with this type of body is called a object message. The ObjectMessage class for C or C++ and IObjectMessage interface for .NET contain the methods to process the body of an object message.
Stream
The body contains a stream of values, where each value has an associated data type. A message with this type of body is called a stream message. The StreamMessage class for C or C++ and IStreamMessage interface for .NET contain the methods to process the body of a stream message.
Text
The body contains a string. A message with this type of body is called a text message. The TextMessage class for C or C++ and ITextMessage interface for .NET contain the methods to process the body of a text message.

In the C interface, XMS returns a message handle to an application when the application creates a message. The application can use this handle to call any of the methods of the Message class, and any of the methods of the BytesMessage, MapMessage, ObjectMessage, StreamMessage, or TextMessage class, whichever is appropriate for the type of message body. However, if an application tries to call a method that is inappropriate for the type of message body, the call fails and XMS returns error code XMS_E_BAD_PARAMETER.

A C application can call the xmsMsgGetTypeId() function to determine the body type of a message. The function returns one of the following values:
XMS_MESSAGE_TYPE_BASE
If the message has no body
XMS_MESSAGE_TYPE_BYTES
If the message is a bytes message
XMS_MESSAGE_TYPE_MAP
If the message is a map message
XMS_MESSAGE_TYPE_OBJECT
If the message is an object message
XMS_MESSAGE_TYPE_STREAM
If the message is a stream message
XMS_MESSAGE_TYPE_TEXT
If the message is a text message
See the following fragment of C code, for example:
xmsMESSAGE_TYPE msgtype;
xmsMsgConsumerReceive(messageConsumer, &msg, errorBlock);
xmsMsgGetTypeId(msg, &msgtype, errorBlock);
if (msgtype == XMS_MESSAGE_TYPE_BYTES)
{
  xmsBytesMsgGetBodyLength(msg, &length, errorBlock);
}

In the C++ interface, BytesMessage, MapMessage, ObjectMessage, StreamMessage, and TextMessage are subclasses of the Message class.

In .NET, the IMessage interface is the parent of all message objects, and can be used in messaging functions to represent any of the XMS message types.

To ensure that XMS applications can exchange messages with WebSphere MQ JMS applications, an XMS application and a WebSphere MQ JMS application must be able to interpret the application data in the body of a message in the same way. For this reason, each element of application data written in the body of a message by an XMS application must have one of the data types listed in Table 1. For each XMS data type, the table shows the compatible Java data type. XMS provides the methods to write elements of application data with these data types, and only these data types.

Table 1. XMS data types that are compatible with Java data types
XMS data type Represents Size Compatible Java data type
xmsBOOL The boolean value xmsTRUE or xmsFALSE 32 bits boolean
xmsCHAR16 Double byte character 16 bits char
xmsSBYTE Signed 8-bit integer 8 bits byte
xmsSHORT Signed 16-bit integer 16 bits short
xmsINT Signed 32-bit integer 32 bits int
xmsLONG Signed 64-bit integer 64 bits long
xmsFLOAT Signed floating point number 32 bits float
xmsDOUBLE Signed double precision floating point number 64 bits double
String String of characters - String

For more information about the five types of body message, see the following topics:

Related reference
Parts of an XMS message
Header fields in an XMS message
Properties of an XMS message
Message selectors
Mapping XMS messages onto WebSphere MQ messages

Reference topic

Terms of Use | Rate this page

Last updated: 7 Dec 2005

© Copyright IBM Corporation 2005. All Rights Reserved.