public final class DefaultEventContext extends Object implements Serializable
EventContext.| Modifier and Type | Method and Description |
|---|---|
static EventContext |
child(EventContext parent)
Builds a new child execution context from a parent context.
|
static EventContext |
create(FlowConstruct flow,
org.mule.runtime.api.component.location.ComponentLocation location)
Builds a new execution context with the given parameters.
|
static EventContext |
create(FlowConstruct flow,
org.mule.runtime.api.component.location.ComponentLocation location,
String correlationId)
Builds a new execution context with the given parameters and an empty publisher.
|
static EventContext |
create(FlowConstruct flow,
org.mule.runtime.api.component.location.ComponentLocation location,
String correlationId,
org.reactivestreams.Publisher<Void> externalCompletionPublisher)
Builds a new execution context with the given parameters.
|
void |
error(Throwable throwable)
Complete this
EventContext unsuccessfully with an error |
org.reactivestreams.Publisher<Event> |
getBeforeResponsePublisher()
A
Publisher that completes when a response is ready or an error was produced for this EventContext but
importantly before the Response Publisher obtained via EventContext.getResponsePublisher() completes. |
org.reactivestreams.Publisher<Void> |
getCompletionPublisher()
|
String |
getCorrelationId()
The correlation ID is used to correlate messages between different flows and systems.
|
String |
getId()
Unique time-based id (UUID) for this
EventContext. |
String |
getOriginatingConnectorName() |
String |
getOriginatingFlowName() |
org.mule.runtime.api.component.location.ComponentLocation |
getOriginatingLocation() |
String |
getOriginatingSourceName() |
Optional<EventContext> |
getParentContext()
Returns
this context's parent if it has one |
ProcessingTime |
getProcessingTime() |
ProcessorsTrace |
getProcessorsTrace()
Events have a list of message processor paths it went trough so that the execution path of an event can be reconstructed
after it has executed.
|
OffsetTime |
getReceivedTime() |
org.reactivestreams.Publisher<Event> |
getResponsePublisher()
A
Publisher that completes when a response is ready or an error was produced for this EventContext. |
boolean |
isCorrelationIdFromSource()
Used to determine if the correlation was set by the source connector or was generated.
|
void |
success()
Complete this
EventContext successfully with no result Event. |
void |
success(Event event)
Complete this
EventContext successfully with a result Event. |
String |
toString() |
public static EventContext create(FlowConstruct flow, org.mule.runtime.api.component.location.ComponentLocation location)
flow - the flow that processes events of this context.location - the location of the component that received the first message for this context.public static EventContext create(FlowConstruct flow, org.mule.runtime.api.component.location.ComponentLocation location, String correlationId)
flow - the flow that processes events of this context.location - the location of the component that received the first message for this context.correlationId - See EventContext.getCorrelationId().public static EventContext create(FlowConstruct flow, org.mule.runtime.api.component.location.ComponentLocation location, String correlationId, org.reactivestreams.Publisher<Void> externalCompletionPublisher)
flow - the flow that processes events of this context.location - the location of the component that received the first message for this context.correlationId - See EventContext.getCorrelationId().externalCompletionPublisher - void publisher that completes when source completes enabling completion of
EventContext to depend on completion of source.public static EventContext child(EventContext parent)
flow-ref type scenarios where a the referenced Flow should complete the child context, but should
not complete the parent contextparent - the parent contextpublic String getId()
EventContextEventContext.getId in interface EventContextEventContextpublic String getCorrelationId()
EventContext
If the connector that receives the source message supports the concept of a correlation ID then the connector should create
an instance of EventContext using this value. If on the other hand, no correlation ID is received by the source
connector then a time-based UUID, also available via EventContext.getId() is used.
getCorrelationId in interface EventContextpublic OffsetTime getReceivedTime()
getReceivedTime in interface EventContextpublic org.mule.runtime.api.component.location.ComponentLocation getOriginatingLocation()
getOriginatingLocation in interface EventContextpublic String getOriginatingFlowName()
getOriginatingFlowName in interface EventContextpublic String getOriginatingConnectorName()
getOriginatingConnectorName in interface EventContextpublic String getOriginatingSourceName()
getOriginatingSourceName in interface EventContextpublic ProcessingTime getProcessingTime()
getProcessingTime in interface EventContextpublic boolean isCorrelationIdFromSource()
EventContextisCorrelationIdFromSource in interface EventContexttrue if the source system provided a correlation id, false otherwise.public ProcessorsTrace getProcessorsTrace()
EventContextDefaultMuleConfiguration.isFlowTrace() is true. If false, the list will
always be empty.getProcessorsTrace in interface EventContextpublic Optional<EventContext> getParentContext()
EventContextthis context's parent if it has onegetParentContext in interface EventContextthis context's parent or Optional.empty() if it doesn't have onepublic final void success()
EventContext successfully with no result Event.success in interface EventContextpublic final void success(Event event)
EventContext successfully with a result Event.success in interface EventContextevent - the result event.public final void error(Throwable throwable)
EventContext unsuccessfully with an errorerror in interface EventContextthrowable - the throwable.public org.reactivestreams.Publisher<Event> getBeforeResponsePublisher()
EventContextPublisher that completes when a response is ready or an error was produced for this EventContext but
importantly before the Response Publisher obtained via EventContext.getResponsePublisher() completes. This allows for
response subscribers that are executed before the source, client or parent flow receives to be registered. In order to
subscribe after response processing you can use the response Publisher.
Any asynchronous processing initiated as part of processing the request Event maybe still be in process when this
Publisher completes. The completion Publisher can be used to perform an action after all processing is
complete.getBeforeResponsePublisher in interface EventContextEventContext instance has a response of error.EventContext.getResponsePublisher(),
EventContext.getCompletionPublisher()public org.reactivestreams.Publisher<Event> getResponsePublisher()
EventContextPublisher that completes when a response is ready or an error was produced for this EventContext.
Any subscribers registered before the response completes will be executed after the response has been processed by the
source, client or parent flow. In order to subscribe before response processing you can use the before response
Publisher.
Any asynchronous processing initiated as part of processing the request Event maybe still be in process when this
Publisher completes. The completion Publisher can be used to perform an action after all processing is
complete.getResponsePublisher in interface EventContextEventContext instance has a response of error.(),
EventContext.getCompletionPublisher()public org.reactivestreams.Publisher<Void> getCompletionPublisher()
EventContextPublisher that completes when a this EventContext and all child EventContext's have
completed. In practice this means that this Publisher completes once all branches of execution have completed
regardless of is they are synchronous or asynchronous. This Publisher will never complete with an error.getCompletionPublisher in interface EventContextEventContext and all child context have completed.Copyright © 2003–2017 MuleSoft, Inc.. All rights reserved.