The JMS API defines the standard form of a JMS message, which should be portable across all JMS providers. Because the JMS API was designed to accommodate many existing providers, the resulting message form encompasses a wide variety of features. Oracle ATG Web Commerce supports all of these features, but internally adheres to conventions that greatly narrow the set of features developers must master.

A JMS message consists of two parts:

Message Header

The header contains system-level information common to all messages, such as the destination and the time it was sent, while the body contains only application-specific data. The header can also contain some application-specific information, stored as keyword/value properties. However, not all providers allow an arbitrary amount of data to be stored in the header, it is a good idea to keep most application-specific data in the message body.

The most important header value is the JMSType. This is a String that is used to identify what kind of message is being sent. Handlers often examine the JMSType to see how they should handle an incoming message.

The header is useful for specifying message selectors. When a receiver subscribes to a destination, it can specify a message selector, which acts as a filter for weeding out messages the receiver does not want to see. The message selector must be specified in terms of the message’s header. For example, a receiver can specify a message selector saying that it wants to see only messages whose JMSType is atg.das.Startup. The message selector can refer to both system-level and application-specific header properties.

Message Body

To accommodate the various data formats of existing providers, JMS defines five distinct message body types. In the JMS API, these translate into five Java interfaces, each subclassing javax.jms.Message:

Interface

Message Body Type

javax.jms.TextMessage

A block of text, represented in Java as a String. For example, this type of message can be used to represent a message as an XML file.

javax.jms.ObjectMessage

A Java object (which must be serializable). For example, the message can contain a Java Bean whose properties represent the different data elements of the message.

javax.jms.MapMessage

A set of keyword/value pairs.

javax.jms.BytesMessage

A block of binary data, represented in Java as a byte array. This format is often used to interface with an external messaging system that defines its own binary protocol for message formats.

javax.jms.StreamMessage

A list of Java primitive values. This type can be used to represent certain data types used by existing messaging systems.

JMS systems can support all, or only a subset, of these message formats. Oracle ATG Web Commerce’s JMS providers support the subset described in the next section.


Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices