public class SimpleEventHandlerInvoker extends Object implements EventHandlerInvoker
EventHandlerInvoker that forwards events to a list of registered EventMessageHandler.| Modifier and Type | Class and Description |
|---|---|
static class |
SimpleEventHandlerInvoker.Builder<B extends SimpleEventHandlerInvoker.Builder<?>>
Builder class to instantiate a
SimpleEventHandlerInvoker. |
| Modifier | Constructor and Description |
|---|---|
protected |
SimpleEventHandlerInvoker(SimpleEventHandlerInvoker.Builder<?> builder)
Instantiate a
SimpleEventHandlerInvoker based on the fields contained in the SimpleEventHandlerInvoker.Builder. |
| Modifier and Type | Method and Description |
|---|---|
static <B extends SimpleEventHandlerInvoker.Builder<?>> |
builder()
Instantiate a Builder to be able to create a
SimpleEventHandlerInvoker. |
boolean |
canHandle(EventMessage<?> eventMessage,
Segment segment)
Check whether or not this invoker has handlers that can handle the given
eventMessage for a given segment. |
boolean |
canHandleType(Class<?> payloadType)
Check whether or not this invoker has handlers that can handle the given
payloadType. |
List<EventMessageHandler> |
eventHandlers()
Gets the list of
EventMessageHandler delegates in this invoker. |
ListenerInvocationErrorHandler |
getListenerInvocationErrorHandler()
Return the
ListenerInvocationErrorHandler as configured for this EventHandlerInvoker. |
SequencingPolicy<? super EventMessage<?>> |
getSequencingPolicy()
Return the
SequencingPolicy as configured for this EventHandlerInvoker. |
void |
handle(EventMessage<?> message,
Segment segment)
Handle the given
message for the given segment. |
protected void |
invokeHandlers(EventMessage<?> message) |
void |
performReset()
Performs any activities that are required to reset the state managed by handlers assigned to this invoker.
|
<R> void |
performReset(R resetContext)
Performs any activities that are required to reset the state managed by handlers assigned to this invoker.
|
protected Object |
sequenceIdentifier(EventMessage<?> event) |
protected boolean |
sequencingPolicyMatchesSegment(EventMessage<?> message,
Segment segment) |
boolean |
supportsReset()
Indicates whether the handlers managed by this invoker support a reset.
|
protected SimpleEventHandlerInvoker(SimpleEventHandlerInvoker.Builder<?> builder)
SimpleEventHandlerInvoker based on the fields contained in the SimpleEventHandlerInvoker.Builder.
Will assert that at least one EventMessageHandler is provided, and will throw an AxonConfigurationException if this is not the case.
builder - the SimpleEventHandlerInvoker.Builder used to instantiate a SimpleEventHandlerInvoker instancepublic static <B extends SimpleEventHandlerInvoker.Builder<?>> SimpleEventHandlerInvoker.Builder<B> builder()
SimpleEventHandlerInvoker.
The ListenerInvocationErrorHandler is defaulted to a LoggingErrorHandler and the
SequencingPolicy to a SequentialPerAggregatePolicy. Providing at least one Event Handler is a
hard requirement and as such should be provided.
B - An implementation of SimpleEventHandlerInvoker.Builder.SimpleEventHandlerInvoker.public List<EventMessageHandler> eventHandlers()
EventMessageHandler delegates in this invoker. These delegates are the end point of
event handling.EventMessageHandler delegates.public void handle(@Nonnull EventMessage<?> message, @Nonnull Segment segment) throws Exception
EventHandlerInvokermessage for the given segment.
Callers are recommended to invoke EventHandlerInvoker.canHandle(EventMessage, Segment) prior to invocation, but aren't
required to do so. Implementations must ensure to take the given segment into account when processing messages.
handle in interface EventHandlerInvokermessage - The message to handlesegment - The segment for which to handle the messageException - when an exception occurs while handling the messageprotected boolean sequencingPolicyMatchesSegment(EventMessage<?> message, Segment segment)
protected Object sequenceIdentifier(EventMessage<?> event)
protected void invokeHandlers(EventMessage<?> message) throws Exception
Exceptionpublic boolean canHandle(@Nonnull EventMessage<?> eventMessage, @Nonnull Segment segment)
EventHandlerInvokereventMessage for a given segment.canHandle in interface EventHandlerInvokereventMessage - The message to be processedsegment - The segment for which the event handler should be invokedtrue if the invoker has one or more handlers that can handle the given message, false
otherwisepublic boolean canHandleType(@Nonnull Class<?> payloadType)
EventHandlerInvokerpayloadType.canHandleType in interface EventHandlerInvokerpayloadType - The payloadType of the message to be processedtrue if the invoker has one or more handlers that can handle the given message, false
otherwisepublic boolean supportsReset()
EventHandlerInvokersupportsReset in interface EventHandlerInvokertrue if a reset is supported, otherwise falsepublic void performReset()
EventHandlerInvokerperformReset in interface EventHandlerInvokerpublic <R> void performReset(@Nullable R resetContext)
EventHandlerInvokerperformReset in interface EventHandlerInvokerR - the type of the provided resetContextresetContext - a R used to support the reset operationpublic ListenerInvocationErrorHandler getListenerInvocationErrorHandler()
ListenerInvocationErrorHandler as configured for this EventHandlerInvoker.ListenerInvocationErrorHandler as configured for this EventHandlerInvokerpublic SequencingPolicy<? super EventMessage<?>> getSequencingPolicy()
SequencingPolicy as configured for this EventHandlerInvoker.SequencingPolicy as configured for this EventHandlerInvokerCopyright © 2010–2023. All rights reserved.