Class Hierarchy All Classes All Fields and Methods

Class com.ibm.broker.plugin.MbMessage

java.lang.Object
        com.ibm.broker.plugin.MbMessage

public class MbMessage
extends Object

MbMessage represents the message passed between the nodes in a message flow. A message in its raw form is a sequence of bytes known as the wire format . Nodes within the broker will navigate and manipulate the message using a logical format whereby the message is represented as a hierarchical tree of syntax elements. Conversion between these two formats is managed by parsers. Different parsers are invoked by the root parser as required during the parsing of a message. The following diagram shows a typical message.

                 +----+
                 |Root|
                 +----+
                 /    \
               /        \
             /            \
           /                \
         /                    \
    +----------+   +----+   +---+
    |Properties|---|MQMD|---|XML|
    +----------+   +----+   +---+
 
The root parser at the top will invoke the parsers along the bottom in the order shown to parse the bitstream into a syntax element tree. This tree will then have same structure as shown in the diagram with sub-trees off each parser element representing its part of the message. For example the MQMD header is the first sibling of the first child of Root and the MQMD attributes are children of this.

The syntax element representing the root is returned by getRootElement. This is an object of type MbElement which contains methods to navigate and modify the tree.

Field Index
Field Description
FINALIZE_NONE Option for finalizeMessage.
FINALIZE_VALIDATE Option for finalizeMessage.
Constructor Index
Constructor Description
MbMessage() Default constructor for MbMessage
MbMessage(MbMessage) Copy constructor for MbMessage.
Method Index
Method Description
void clearMessage() Deletes the resources associated with the message.
Object evaluateXPath(MbXPath) Evaluates the XPath 1.0 expression with the message body (last child of root) as the context node.
Object evaluateXPath(String) Evaluates the XPath 1.0 expression with the message body (last child of root) as the context node.
void finalizeMessage(int) Causes the broker to request parsers that support the finalize feature to perform their finalize processing on the message.
byte[] getBuffer() Get a copy of the data buffer associated with (and owned by) the message object.
MbElement getRootElement() Get the root syntax element associated with the message.
String toString() Returns a String representation of the MbMessage.

Fields

FINALIZE_NONE

public static final int FINALIZE_NONE

Option for finalizeMessage.

FINALIZE_VALIDATE

public static final int FINALIZE_VALIDATE

Option for finalizeMessage.

Constructors

MbMessage

public MbMessage() throws MbException

Default constructor for MbMessage

MbMessage

public MbMessage(MbMessage message) throws MbException

Copy constructor for MbMessage. An MbMessage object can only be created based on an existing message.

Methods

clearMessage

public void clearMessage() throws MbException

Deletes the resources associated with the message. Propagating the message or referencing it after clearMessage has been called will result in indeterminate behavior.

evaluateXPath

public Object evaluateXPath(MbXPath xpath) throws MbException

Evaluates the XPath 1.0 expression with the message body (last child of root) as the context node. The return type depends on the expression and can be one of:

evaluateXPath

public Object evaluateXPath(String expression) throws MbException

Evaluates the XPath 1.0 expression with the message body (last child of root) as the context node. The return type depends on the expression and can be one of:

This is a convenience method for evaluateXPath(new MbXPath(expression));

finalizeMessage

public void finalizeMessage(int options) throws MbException

Causes the broker to request parsers that support the finalize feature to perform their finalize processing on the message. The behavior of this processing is specific to each parser.

Of the options parameter is set to FINALIZE_VALIDATE, a parser should also perform validation processing to ensure that the element tree owned by it is of the correct structure. This helps prevent messages with incorrectly formed element trees being propagated to other nodes in the message flow.

It is recommended that finalizeMessage is called prior to propagating a message.

getBuffer

public byte[] getBuffer() throws MbException

Get a copy of the data buffer associated with (and owned by) the message object. Causes the syntax element tree associated with the message to be written to the data buffer owned by that message object. This operation serializes the element tree into a bitstream, which is then returned as a sequence of contiguous bytes. This method should be used when writing the bitsream to a target that is outside the broker (that is, when writing a plug-in output node).

getRootElement

public MbElement getRootElement() throws MbException

Get the root syntax element associated with the message. When a message object is constructed by the broker, a root element is automatically created.

toString

public String toString() 

Returns a String representation of the MbMessage.

Class Hierarchy All Classes All Fields and Methods