public interface MuleMessage extends Serializable
MuleMessage
represents a message payload. The Message comprises of
the payload itself and properties associated with the payload.Modifier and Type | Method and Description |
---|---|
void |
addAttachment(String name,
DataHandler dataHandler)
Deprecated.
|
void |
addOutboundAttachment(String name,
DataHandler dataHandler)
Allows for arbitrary data attachments to be associated with the Message.
|
void |
addOutboundAttachment(String name,
Object object,
String contentType)
Adds an outgoing attachment to the message
|
void |
addProperties(Map<String,Object> properties)
Deprecated.
|
void |
addProperties(Map<String,Object> properties,
PropertyScope scope)
Adds a map of properties to be associated with this message
|
void |
applyTransformers(MuleEvent event,
List<? extends Transformer> transformers)
Will apply a list of transformers to the payload of the message.
|
void |
applyTransformers(MuleEvent event,
List<? extends Transformer> transformers,
Class<?> outputType)
Will apply a list of transformers to the payload of the message.
|
void |
applyTransformers(MuleEvent event,
Transformer... transformers)
Will apply a list of transformers to the payload of the message.
|
void |
clearAttachments()
Removes all outbound attachments on this message.
|
void |
clearProperties()
Deprecated.
|
void |
clearProperties(PropertyScope scope)
Removes all properties on this message in the given scope.
|
MuleMessage |
createInboundMessage()
Copy an inbound message to an outbound one, moving all message properties and attachments
|
<T> T |
findPropertyInAnyScope(String name,
T defaultValue)
This method was added with the introduction of Property scopes.
|
DataHandler |
getAttachment(String name)
Deprecated.
use
getInboundAttachment(String) instead |
Set<String> |
getAttachmentNames()
Deprecated.
|
boolean |
getBooleanProperty(String name,
boolean defaultValue)
Deprecated.
use
getInboundProperty(String, Object) instead |
int |
getCorrelationGroupSize()
Determines how many messages are in the correlation group
|
String |
getCorrelationId()
Sets a correlationId for this message.
|
int |
getCorrelationSequence()
Gets the sequence or ordering number for this message in the the correlation
group (as defined by the correlationId)
|
DataType<?> |
getDataType()
Returns the data type (if any) associated with the message's payload.
|
double |
getDoubleProperty(String name,
double defaultValue)
Deprecated.
use
getInboundProperty(String, Object) instead |
String |
getEncoding()
Gets the encoding for the current message.
|
ExceptionPayload |
getExceptionPayload()
If an error occurred during the processing of this message this will return a
ErrorPayload that contains the root exception and Mule error code, plus any
other releated info
|
DataHandler |
getInboundAttachment(String name)
Retrieve an attachment with the given name.
|
Set<String> |
getInboundAttachmentNames() |
<T> T |
getInboundProperty(String name) |
<T> T |
getInboundProperty(String name,
T defaultValue) |
Set<String> |
getInboundPropertyNames() |
int |
getIntProperty(String name,
int defaultValue)
Deprecated.
use
getInboundProperty(String, Object) instead |
<T> T |
getInvocationProperty(String name) |
<T> T |
getInvocationProperty(String name,
T defaultValue) |
Set<String> |
getInvocationPropertyNames() |
long |
getLongProperty(String name,
long defaultValue)
Deprecated.
use
getInboundProperty(String, Object) instead |
String |
getMessageRootId()
gets an identifier that is the same among parent and child messages
|
MuleContext |
getMuleContext()
Deprecated.
Avoid getting access to the MuleContext through the message.
You can get access to the MuleContext by making your class implement
MuleContextAware |
Object |
getOriginalPayload()
Returns the original payload used to create this message.
|
DataHandler |
getOutboundAttachment(String name)
Retrieve an attachment with the given name.
|
Set<String> |
getOutboundAttachmentNames() |
<T> T |
getOutboundProperty(String name) |
<T> T |
getOutboundProperty(String name,
T defaultValue) |
Set<String> |
getOutboundPropertyNames() |
Object |
getPayload() |
<T> T |
getPayload(Class<T> outputType)
Will attempt to obtain the payload of this message with the desired Class type.
|
<T> T |
getPayload(DataType<T> outputType)
Will attempt to obtain the payload of this message with the desired Class type.
|
byte[] |
getPayloadAsBytes()
Converts the message implementation into a byte array representation
|
String |
getPayloadAsString()
Converts the message implementation into a String representation.
|
String |
getPayloadAsString(String encoding)
Converts the message implementation into a String representation
|
String |
getPayloadForLogging()
Get the message payload for logging without throwing exception
Converts the message implementation into a String representation.
|
String |
getPayloadForLogging(String encoding)
Get the message payload for logging without throwing exception
Converts the message implementation into a String representation.
|
Object |
getProperty(String key)
Deprecated.
use the overloaded version with an explicit lookup scope. This method will
now use only the outbound scope.
|
Object |
getProperty(String name,
Object defaultValue)
Deprecated.
use scope-aware methods instead
|
<T> T |
getProperty(String name,
PropertyScope scope)
Gets a property from the message with a given scope.
|
<T> T |
getProperty(String name,
PropertyScope scope,
T defaultValue)
Gets a property from the message with a given scope and provides a default value if the property is not
present on the message in the scope specified.
|
DataType<?> |
getPropertyDataType(String name,
PropertyScope scope)
Gets a property data type from the message with a given scope.
|
Set<String> |
getPropertyNames()
Deprecated.
|
Set<String> |
getPropertyNames(PropertyScope scope)
Gets all property names in a given scope.
|
Object |
getReplyTo()
Returns a replyTo address for this message.
|
<T> T |
getSessionProperty(String name)
Deprecated.
|
<T> T |
getSessionProperty(String name,
T defaultValue)
Deprecated.
|
Set<String> |
getSessionPropertyNames()
Deprecated.
|
String |
getStringProperty(String name,
String defaultValue)
Deprecated.
use
getInboundProperty(String, Object) instead |
String |
getUniqueId()
gets the unique identifier for the message.
|
void |
propagateRootId(MuleMessage parent)
copy the message root id from parent to child
|
void |
release()
Perform any clean up operations on the message resource.
|
void |
removeAttachment(String name)
Deprecated.
use
removeOutboundAttachment(java.lang.String) instead |
void |
removeOutboundAttachment(String name)
Remove an attachment form this message with the specified name
|
Object |
removeProperty(String key)
Deprecated.
|
Object |
removeProperty(String key,
PropertyScope scope)
Removes a property on this message from the specified scope only.
|
void |
setBooleanProperty(String name,
boolean value)
Deprecated.
use
setOutboundProperty(String, Object) instead |
void |
setCorrelationGroupSize(int size)
Determines how many messages are in the correlation group
|
void |
setCorrelationId(String id)
Sets a correlationId for this message.
|
void |
setCorrelationSequence(int sequence)
Gets the sequence or ordering number for this message in the the correlation
group (as defined by the correlationId)
|
void |
setDoubleProperty(String name,
double value)
Deprecated.
use
setOutboundProperty(String, Object) instead |
void |
setEncoding(String encoding)
Sets the encoding for this message
|
void |
setExceptionPayload(ExceptionPayload payload)
If an error occurs while processing this message, a ErrorPayload is attached
which contains the root exception and Mule error code, plus any other releated
info.
|
void |
setIntProperty(String name,
int value)
Deprecated.
use
setOutboundProperty(String, Object) instead |
void |
setInvocationProperty(String key,
Object value) |
void |
setInvocationProperty(String key,
Object value,
DataType<?> dataType) |
void |
setLongProperty(String name,
long value)
Deprecated.
use
setOutboundProperty(String, Object) instead |
void |
setMessageRootId(String rootId)
set the root ID for the message
|
void |
setOutboundProperty(String key,
Object value) |
void |
setOutboundProperty(String key,
Object value,
DataType<?> dataType) |
void |
setPayload(Object payload)
Update the message payload.
|
void |
setPayload(Object payload,
DataType<?> dataType)
Updates the message payload.
|
void |
setProperty(String key,
Object value)
Deprecated.
use
setProperty(String, Object, org.mule.api.transport.PropertyScope) or
preferrably any of the scope-specific set methods. |
void |
setProperty(String key,
Object value,
PropertyScope scope)
Set a property on the message.
|
void |
setProperty(String key,
Object value,
PropertyScope scope,
DataType<?> dataType)
Sets a property on the message
|
void |
setReplyTo(Object replyTo)
Sets a replyTo address for this message.
|
void |
setSessionProperty(String key,
Object value)
Deprecated.
|
void |
setStringProperty(String name,
String value)
Deprecated.
use
setOutboundProperty(String, Object) instead |
@Deprecated void addProperties(Map<String,Object> properties)
addProperties(java.util.Map, org.mule.api.transport.PropertyScope)
insteadproperties
- the properties add to this messagevoid addProperties(Map<String,Object> properties, PropertyScope scope)
properties
- the properties add to this messagescope
- the scope in which the properties should be added@Deprecated void clearProperties()
clearProperties(org.mule.api.transport.PropertyScope)
insteadPropertyScope.INVOCATION
and
PropertyScope.OUTBOUND
.void clearProperties(PropertyScope scope)
scope
- the property scope to clearUnsupportedOperationException
- if scope specified is PropertyScope.INBOUND
@Deprecated Object getProperty(String key)
@Deprecated void setProperty(String key, Object value)
setProperty(String, Object, org.mule.api.transport.PropertyScope)
or
preferrably any of the scope-specific set methods.key
- the key on which to associate the valuevalue
- the property valuesetInvocationProperty(String, Object)
,
setOutboundProperty(String, Object)
,
setSessionProperty(String, Object)
void setProperty(String key, Object value, PropertyScope scope)
key
- the key on which to associate the valuevalue
- the property valuescope
- The scope at which to set the property atPropertyScope
,
setInvocationProperty(String, Object)
,
setOutboundProperty(String, Object)
,
setSessionProperty(String, Object)
void setProperty(String key, Object value, PropertyScope scope, DataType<?> dataType)
key
- the key on which to associate the valuevalue
- the property valuescope
- The scope at which to set the property atdataType
- the data type for the property value@Deprecated Object removeProperty(String key)
removeProperty(String, org.mule.api.transport.PropertyScope)
key
- the property key to removeObject removeProperty(String key, PropertyScope scope)
key
- the property key to removescope
- The scope at which to set the property at@Deprecated Set<String> getPropertyNames()
getPropertyNames(org.mule.api.transport.PropertyScope)
Set<String> getPropertyNames(PropertyScope scope)
scope
- the scope of property namesgetInvocationPropertyNames()
,
getInboundPropertyNames()
,
getOutboundPropertyNames()
,
getSessionPropertyNames()
@Deprecated Set<String> getSessionPropertyNames()
Object getPayload()
String getUniqueId()
String getMessageRootId()
void setMessageRootId(String rootId)
void propagateRootId(MuleMessage parent)
@Deprecated Object getProperty(String name, Object defaultValue)
name
- the name or key of the property. This must be non-null.defaultValue
- a default value if the property doesn't exist in the event. This can be null.getInboundProperty(String)
,
getOutboundProperty(String)
,
getInvocationProperty(String)
,
getSessionProperty(String)
<T> T getProperty(String name, PropertyScope scope)
name
- the name or key of the property. This must be non-null.scope
- The scope of the property to retrieve. This must be non-null.getInboundProperty(String)
,
getOutboundProperty(String)
,
getInvocationProperty(String)
,
getSessionProperty(String)
<T> T getInboundProperty(String name, T defaultValue)
<T> T getInboundProperty(String name)
<T> T getInvocationProperty(String name, T defaultValue)
<T> T getInvocationProperty(String name)
<T> T getOutboundProperty(String name, T defaultValue)
<T> T getOutboundProperty(String name)
<T> T findPropertyInAnyScope(String name, T defaultValue)
T
- The Type of the property value that will be returnedname
- the name of the property to look fordefaultValue
- the default value that will be returned if the property is not found<T> T getProperty(String name, PropertyScope scope, T defaultValue)
T
- the defaultValue type ,this is used to validate the property value typename
- the name or key of the property. This must be non-null.scope
- The scope of the property to retrieve. This must be non-null.defaultValue
- the value to return if the property is not in the scope provided. Can be nullIllegalArgumentException
- if the value for the property key is not assignable from the defaultValue typeDataType<?> getPropertyDataType(String name, PropertyScope scope)
name
- the name or key of the property. This must be non-null.scope
- The scope of the property to retrieve. This must be non-null.@Deprecated int getIntProperty(String name, int defaultValue)
getInboundProperty(String, Object)
insteadname
- the name or key of the propertydefaultValue
- a default value if the property doesn't exist in the event@Deprecated long getLongProperty(String name, long defaultValue)
getInboundProperty(String, Object)
insteadname
- the name or key of the propertydefaultValue
- a default value if the property doesn't exist in the event@Deprecated double getDoubleProperty(String name, double defaultValue)
getInboundProperty(String, Object)
insteadname
- the name or key of the propertydefaultValue
- a default value if the property doesn't exist in the event@Deprecated String getStringProperty(String name, String defaultValue)
getInboundProperty(String, Object)
insteadname
- the name or key of the propertydefaultValue
- a default value if the property doesn't exist in the event@Deprecated boolean getBooleanProperty(String name, boolean defaultValue)
getInboundProperty(String, Object)
insteadname
- the name or key of the propertydefaultValue
- a default value if the property doesn't exist in the event@Deprecated void setBooleanProperty(String name, boolean value)
setOutboundProperty(String, Object)
insteadname
- the property name or keyvalue
- the property value@Deprecated void setIntProperty(String name, int value)
setOutboundProperty(String, Object)
insteadname
- the property name or keyvalue
- the property value@Deprecated void setLongProperty(String name, long value)
setOutboundProperty(String, Object)
insteadname
- the property name or keyvalue
- the property value@Deprecated void setDoubleProperty(String name, double value)
setOutboundProperty(String, Object)
insteadname
- the property name or keyvalue
- the property value@Deprecated void setStringProperty(String name, String value)
setOutboundProperty(String, Object)
insteadname
- the property name or keyvalue
- the property valuevoid setCorrelationId(String id)
id
- the Id reference for this relationshipString getCorrelationId()
int getCorrelationSequence()
void setCorrelationSequence(int sequence)
sequence
- the sequence number or -1 if the sequence is not importantint getCorrelationGroupSize()
void setCorrelationGroupSize(int size)
size
- the total messages in this group or -1 if the size is not knownvoid setReplyTo(Object replyTo)
replyTo
- the endpointUri url to reply toObject getReplyTo()
ExceptionPayload getExceptionPayload()
void setExceptionPayload(ExceptionPayload payload)
payload
- The exception payload to attach to this message@Deprecated void addAttachment(String name, DataHandler dataHandler) throws Exception
addOutboundAttachment(java.lang.String, javax.activation.DataHandler)
insteadname
- the name to associate with the attachmentdataHandler
- The attachment datahandler to use. This will be used to
interact with the attachment data.Exception
- if the attachment cannot be added for any reasonDataHandler
void addOutboundAttachment(String name, DataHandler dataHandler) throws Exception
name
- the name to associate with the attachmentdataHandler
- The attachment DataHandler
to use. This will be used to interact with the attachment dataException
- if the attachment cannot be added for any reasonDataHandler
void addOutboundAttachment(String name, Object object, String contentType) throws Exception
object
- the input stream to the contents of the attachment. This object can either be a URL
, which will construct a URL data source, or
a File
, which will construct a file data source. Any other object will be used as the raw contents of the attachmentcontentType
- the content type of the attachment. Note that the charset attribute can be specifed too i.e. text/plain;charset=UTF-8name
- the name to associate with the attachmentsException
- if the attachment cannot be read or created@Deprecated void removeAttachment(String name) throws Exception
removeOutboundAttachment(java.lang.String)
insteadname
- the name of the attachment to remove. If the attachment does not exist, the request may be ignoredException
- different messaging systems handle attachments differently, as such some will throw an exception
if an attachment does dot exist.void removeOutboundAttachment(String name) throws Exception
name
- the name of the attachment to remove. If the attachment does not exist, the request may be ignoredException
- different messaging systems handle attachments differently, as such some will throw an exception
if an attachment does dot exist.@Deprecated DataHandler getAttachment(String name)
getInboundAttachment(String)
insteadname
- the name of the attachment to retrieveDataHandler
DataHandler getInboundAttachment(String name)
name
- the name of the attachment to retrieveDataHandler
DataHandler getOutboundAttachment(String name)
name
- the name of the attachment to retrieveDataHandler
@Deprecated Set<String> getAttachmentNames()
getInboundAttachmentNames()
Set<String> getInboundAttachmentNames()
Set<String> getOutboundAttachmentNames()
String getEncoding()
void setEncoding(String encoding)
encoding
- the encoding to usevoid release()
void applyTransformers(MuleEvent event, List<? extends Transformer> transformers) throws MuleException
event
- the event being processedtransformers
- the transformers to apply to the message payloadTransformerException
- if a transformation error occurs or one or more of the transformers passed in a
are incompatible with the message payloadMuleException
void applyTransformers(MuleEvent event, Transformer... transformers) throws MuleException
event
- the event being processedtransformers
- the transformers to apply to the message payloadTransformerException
- if a transformation error occurs or one or more of the transformers passed in a
are incompatible with the message payloadMuleException
void applyTransformers(MuleEvent event, List<? extends Transformer> transformers, Class<?> outputType) throws MuleException
event
- the event being processedtransformers
- the transformers to apply to the message payloadoutputType
- the required output type for this transformation. by adding this parameter some additional
transformations will occur on the message payload to ensure that the final payload is of the specified type.
If no transformers can be found in the registry that can transform from the return type of the transformation
list to the outputType and exception will be thrownTransformerException
- if a transformation error occurs or one or more of the transformers passed in a
are incompatible with the message payloadMuleException
void setPayload(Object payload)
payload
- the object to assign as the message payloadvoid setPayload(Object payload, DataType<?> dataType)
payload
- the object to assign as the message payloaddataType
- payload's dataType. Not null.<T> T getPayload(Class<T> outputType) throws TransformerException
outputType
- the desired return typeTransformerException
- if a transformer cannot be found or there is an error during transformation of the
payload<T> T getPayload(DataType<T> outputType) throws TransformerException
outputType
- the desired return typeTransformerException
- if a transformer cannot be found or there is an error during transformation of the
payloadString getPayloadAsString(String encoding) throws Exception
encoding
- The encoding to use when transforming the message (if
necessary). The parameter is used when converting from a byte arrayException
- Implementation may throw an endpoint specific exceptionString getPayloadAsString() throws Exception
Exception
- Implementation may throw an endpoint specific exceptionbyte[] getPayloadAsBytes() throws Exception
Exception
- Implemetation may throw an endpoint specific exceptionObject getOriginalPayload()
applyTransformers(MuleEvent,java.util.List)
or
applyTransformers(MuleEvent, java.util.List, Class)
is called.String getPayloadForLogging()
String getPayloadForLogging(String encoding)
@Deprecated MuleContext getMuleContext()
MuleContextAware
DataType<?> getDataType()
@Deprecated <T> T getSessionProperty(String name, T defaultValue)
MuleSession.getProperty(String)
@Deprecated <T> T getSessionProperty(String name)
MuleSession.getProperty(String)
@Deprecated void setSessionProperty(String key, Object value)
MuleSession.setProperty(String, Serializable)
MuleMessage createInboundMessage() throws Exception
Exception
void clearAttachments()
PropertyScope.OUTBOUND
.Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.