Message Package provides an interface to manage the attributes of messages.

Function Description
int getPropertyCount()

Returns a count of the number of properties defined on this message

Iterator<String> getPropertyNames()

Returns an iterator over the defined property names. The returned iterator does not support Iterator.remove

Iterator<Property> getProperties()

Returns an iterator over the properties defined on this message. The returned iterator is not modifiable.

boolean hasProperty(String propertyName);

Returns true if a property with the given name is defined in the message.

boolean hasProperty(StandardMessageProperty property)

Returns true if a property with the given name is defined in the message.

Property getProperty(String propertyName)

Returns the property value associated with the given property value. If no property with the specified value exists a new value is created. To avoid unnecessarily creating new properties, use hasProperty(String) to check for existence.

Property getProperty(StandardMessageProperty property)

Returns the property value associated with the given property value. If no property with the specified value exists a new value is created. To avoid unnecessarily creating new properties, use hasProperty(String) to check for existence.

removeProperty(String propertyName)

Removes the property with the given name. If there is no property with the specified name, this method has no effect.

ReadableBody getBody()

Returns this message's current body. If this message is newly created, this method will return null. ReadableBody objects returned from this method can only be read a single time (in other words, you can only read forwards). This method should be called again if the message needs to be re-read.

WritableBody newBody()

Creates a new body for this message. If this method is called, the newly created body will replace any existing writable body.

Exceptions:

  • MessageException.

String getBodyEncoding()

Returns the character encoding that the message body was encoded with if it was not a binary stream.

setBodyEncoding(String encodingName)

Sets the encoding that was used to transform the message body to a byte stream. If this method is not called, the system-wide default encoding will be assumed and returned by getBodyEncoding(). This sets the encoding for the currently writable message body, and so does not take effect until the new body is persisted.

setBodyEncoding(Charset encoding)

Sets the encoding that was used to transform the message body to a byte stream. If this method is not called, the system-wide default encoding will be assumed and returned by {@link #getBodyEncoding()}. This sets the encoding for the currently writable message body, and so doesn't take effect until the new body is persisted.

addError(String reason)

Adds an error to the message. This will cause the message to go to the error connector. The message will be persisted in its current state.

boolean hasErrors()

 Returns true if the message has errors associated with it. These may not be "new" errors.

List<String> getErrors()

If the message is in the error state this method will return the reasons.

Message spawn()

Creates a copy of the current message. Message properties are duplicated as are message contexts and errors. The new message will point to the current message's existing and pending body. The returned message will have a unique message ID.

Exceptions:

  • MessageException.

Save

Save