public interface Event extends Serializable
Holds a Message payload and provides helper methods for obtaining the data in a format that the receiving Mule component understands. The event can also maintain any number of properties that can be set and retrieved by Mule components.
Message| Modifier and Type | Interface and Description |
|---|---|
static interface |
Event.Builder |
static class |
Event.CurrentEventHolder |
| Modifier and Type | Method and Description |
|---|---|
static Event.Builder |
builder(Event event)
Create new
Event.Builder based on an existing Event instance. |
static Event.Builder |
builder(EventContext context)
Create new
Event.Builder. |
static Event.Builder |
builder(EventContext context,
Event event)
|
EventContext |
getContext() |
String |
getCorrelationId()
The returned value will depend on the
MessageSource that created this event, and the flow that is executing the
event. |
static Event |
getCurrentEvent()
Return the event associated with the currently executing thread.
|
Optional<org.mule.runtime.api.message.Error> |
getError()
When a mule component throws an error then an
Error object gets generated with all the data associated to the error. |
FlowCallStack |
getFlowCallStack()
Events have a stack of executed flows (same as a call stack), so that at any given instant an application developer can
determine where this event came from.
|
FlowConstruct |
getFlowConstruct()
Deprecated.
TODO MULE-10013 remove this
|
GroupCorrelation |
getGroupCorrelation()
Returns the correlation metadata of this message.
|
String |
getLegacyCorrelationId()
Deprecated.
TODO MULE-10706 Mule 4: remove this
|
org.mule.runtime.api.message.Message |
getMessage()
Returns the message payload for this event
|
byte[] |
getMessageAsBytes(MuleContext muleContext)
Deprecated.
TODO MULE-10013 Move message serialization logic from within the message to an external service
|
String |
getMessageAsString(Charset encoding,
MuleContext muleContext)
Deprecated.
TODO MULE-10013 Move message serialization logic from within the message to an external service
|
String |
getMessageAsString(MuleContext muleContext)
Deprecated.
TODO MULE-10013 Move message serialization logic from within the message to an external service
|
MuleContext |
getMuleContext()
Deprecated.
TODO MULE-10013 remove this
|
Map<String,org.mule.runtime.api.metadata.TypedValue<Object>> |
getParameters()
Returns the complete set of parameters in the current event
|
Map<String,org.mule.runtime.api.metadata.TypedValue<Object>> |
getProperties()
Returns the complete set of properties in the current event
|
Object |
getReplyToDestination()
Deprecated.
TODO MULE-10739 Move ReplyToHandler to compatibility module.
|
ReplyToHandler |
getReplyToHandler()
Deprecated.
TODO MULE-10739 Move ReplyToHandler to compatibility module.
|
SecurityContext |
getSecurityContext()
The security context for this session.
|
MuleSession |
getSession()
Deprecated.
Transport infrastructure is deprecated.
|
<T> org.mule.runtime.api.metadata.TypedValue<T> |
getVariable(String key)
Returns the variable registered under the given
key |
Set<String> |
getVariableNames()
Returns an immutable
Set of variable names. |
static <T> T |
getVariableValueOrNull(String key,
Event event)
Helper method to get the value of a given variable in a null-safe manner such that
null is returned for non-existent
variables rather than a NoSuchElementException exception being thrown. |
boolean |
isNotificationsEnabled()
Indicates if notifications should be fired when processing this message.
|
static void |
setCurrentEvent(Event event)
Set the event to be associated with the currently executing thread.
|
<T> T |
transformMessage(Class<T> outputType,
MuleContext muleContext)
Deprecated.
TODO MULE-10013 Move message serialization logic from within the message to an external service
|
Object |
transformMessage(org.mule.runtime.api.metadata.DataType outputType,
MuleContext muleContext)
Deprecated.
TODO MULE-10013 Move message serialization logic from within the message to an external service
|
String |
transformMessageToString(MuleContext muleContext)
Deprecated.
TODO MULE-10013 Move message serialization logic from within the message to an external service
|
EventContext getContext()
Event from a MessageSource.GroupCorrelation getGroupCorrelation()
GroupCorrelation.String getCorrelationId()
MessageSource that created this event, and the flow that is executing the
event.<T> org.mule.runtime.api.metadata.TypedValue<T> getVariable(String key)
keyT - the type of the variable value.key - the name or key of the variable. This must be non-null.TypedValue containing the variable's value and DataTypeNoSuchElementException - if the flow variable does not exist.Set<String> getVariableNames()
Set of variable names.Map<String,org.mule.runtime.api.metadata.TypedValue<Object>> getProperties()
Map containing the properties' name as key and the TypedValue as valueMap<String,org.mule.runtime.api.metadata.TypedValue<Object>> getParameters()
Map containing the parameters' name as key and the TypedValue as valueorg.mule.runtime.api.message.Message getMessage()
Optional<org.mule.runtime.api.message.Error> getError()
Error object gets generated with all the data associated to the error.
This field will only contain a value within the error handler defined to handle errors. After the error handler is executed
the event error field will be cleared. If another flow is called from within the error handler the flow will still have
access to the error field.
To avoid losing the error field after the error handler the user can define a variable pointing to the error field.@Deprecated byte[] getMessageAsBytes(MuleContext muleContext) throws org.mule.runtime.api.exception.MuleException
muleContext - the Mule node.org.mule.runtime.api.exception.MuleException - if the message cannot be converted into an array of bytes@Deprecated <T> T transformMessage(Class<T> outputType, MuleContext muleContext) throws TransformerException
outputType - The requested output type.muleContext - the Mule node.TransformerException - if a failure occurs in the transformerif the transform fails or the outputtype is null@Deprecated Object transformMessage(org.mule.runtime.api.metadata.DataType outputType, MuleContext muleContext) throws TransformerException
outputType - The requested output type.muleContext - the Mule node.TransformerException - if a failure occurs in the transformerif the transform fails or the outputtype is null@Deprecated String transformMessageToString(MuleContext muleContext) throws TransformerException
muleContext - the Mule node.TransformerException - if a failure occurs in the transformerTransformer@Deprecated String getMessageAsString(MuleContext muleContext) throws org.mule.runtime.api.exception.MuleException
muleContext - the Mule node.org.mule.runtime.api.exception.MuleException - if the message cannot be converted into a string@Deprecated String getMessageAsString(Charset encoding, MuleContext muleContext) throws org.mule.runtime.api.exception.MuleException
encoding - the encoding to use when converting the message to stringmuleContext - the Mule node.org.mule.runtime.api.exception.MuleException - if the message cannot be converted into a string@Deprecated MuleSession getSession()
@Deprecated FlowConstruct getFlowConstruct()
@Deprecated MuleContext getMuleContext()
@Deprecated ReplyToHandler getReplyToHandler()
@Deprecated Object getReplyToDestination()
boolean isNotificationsEnabled()
FlowCallStack getFlowCallStack()
This will only be enabled if DefaultMuleConfiguration.isFlowTrace() is true. If false, the stack will
always be empty.
SecurityContext getSecurityContext()
@Deprecated String getLegacyCorrelationId()
static Event.Builder builder(EventContext context)
Event.Builder.context - the context to create event instance with.static Event.Builder builder(Event event)
Event.Builder based on an existing Event instance. The existing EventContext is conserved.event - existing event to use as a template to create builder instancestatic Event.Builder builder(EventContext context, Event event)
Event.Builder based on an existing Event instance and and EventContext. A new
EventContext is used instead of the existing instance referenced by the existing Event. This builder should
only be used in some specific scenarios like flow-ref where a new Flow executing the same Event needs a new
context.event - existing event to use as a template to create builder instancecontext - the context to create event instance with.static <T> T getVariableValueOrNull(String key, Event event)
null is returned for non-existent
variables rather than a NoSuchElementException exception being thrown.T - the variable typekey - the key of the variable to retrieve.event - the event from which to retrieve a variable with the given key.null.getVariable(String)static Event getCurrentEvent()
static void setCurrentEvent(Event event)
event - event for currently executing thread.Copyright © 2003–2017 MuleSoft, Inc.. All rights reserved.