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 bit stream 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 | Description |
---|---|
FINALIZE_NONE | Option for finalizeMessage. |
FINALIZE_VALIDATE | Option for finalizeMessage. |
Constructor | Description |
---|---|
MbMessage() | Default constructor for MbMessage |
MbMessage(MbMessage) | Copy constructor for MbMessage. |
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. |
public static final int FINALIZE_NONEOption for finalizeMessage.
public static final int FINALIZE_VALIDATEOption for finalizeMessage.
public MbMessage() throws MbExceptionDefault constructor for MbMessage
- Throws
public MbMessage(MbMessage message) throws MbExceptionCopy constructor for MbMessage. An MbMessage object can only be created based on an existing message.
- Throws
public void clearMessage() throws MbExceptionDeletes the resources associated with the message. Propagating the message or referencing it after clearMessage has been called will result in indeterminate behavior.
- Throws
public Object evaluateXPath(MbXPath xpath) throws MbExceptionEvaluates 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:
Boolean
Double
String
java.util.List
of MbElement objects representing an XPath 1.0 nodeset
- Parameters
- xpath - The MbXPath object representing the XPath 1.0 expression.
- Throws
MbException
- An exception was thrown during the compilation of the expression.
public Object evaluateXPath(String expression) throws MbExceptionEvaluates 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));
Boolean
Double
String
java.util.List
of MbElement objects representing an XPath 1.0 nodeset
- Parameters
- expression - The XPath 1.0 expression.
- Throws
MbException
- An exception was thrown during the compilation of the expression.
public void finalizeMessage(int options) throws MbExceptionCauses 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.
- Parameters
- options - The options governing the method. Acceptable values are: FINALIZE_NONE FINALIZE_VALIDATE
- Throws
public byte[] getBuffer() throws MbExceptionGet 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 bit stream, 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 user-defined output node).
- Returns
- The byte array containing the message buffer.
- Throws
public MbElement getRootElement() throws MbExceptionGet the root syntax element associated with the message. When a message object is constructed by the broker, a root element is automatically created.
- Returns
- MbElement representing the root element.
- Throws
public String toString()Returns a String representation of the MbMessage.
- Returns
- String representing the message.
- Overrides
- toString in class Object