Package org.axonframework.eventhandling
Class SimpleEventHandlerInvoker
java.lang.Object
org.axonframework.eventhandling.SimpleEventHandlerInvoker
- All Implemented Interfaces:
EventHandlerInvoker
- Direct Known Subclasses:
DeadLetteringEventHandlerInvoker
Implementation of an
EventHandlerInvoker that forwards events to a list of registered EventMessageHandler.- Since:
- 3.0
- Author:
- Rene de Waele
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aSimpleEventHandlerInvoker. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aSimpleEventHandlerInvokerbased on the fields contained in theSimpleEventHandlerInvoker.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic <B extends SimpleEventHandlerInvoker.Builder<?>>
SimpleEventHandlerInvoker.Builder<B> builder()Instantiate a Builder to be able to create aSimpleEventHandlerInvoker.booleancanHandle(EventMessage<?> eventMessage, Segment segment) Check whether or not this invoker has handlers that can handle the giveneventMessagefor a givensegment.booleancanHandleType(Class<?> payloadType) Check whether or not this invoker has handlers that can handle the givenpayloadType.Gets the list ofEventMessageHandlerdelegates in this invoker.Return theListenerInvocationErrorHandleras configured for thisEventHandlerInvoker.SequencingPolicy<? super EventMessage<?>> Return theSequencingPolicyas configured for thisEventHandlerInvoker.voidhandle(EventMessage<?> message, Segment segment) Handle the givenmessagefor the givensegment.protected voidinvokeHandlers(EventMessage<?> message) voidPerforms any activities that are required to reset the state managed by handlers assigned to this invoker.<R> voidperformReset(R resetContext) Performs any activities that are required to reset the state managed by handlers assigned to this invoker.protected ObjectsequenceIdentifier(EventMessage<?> event) protected booleansequencingPolicyMatchesSegment(EventMessage<?> message, Segment segment) booleanIndicates whether the handlers managed by this invoker support a reset.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.eventhandling.EventHandlerInvoker
segmentReleased
-
Constructor Details
-
SimpleEventHandlerInvoker
Instantiate aSimpleEventHandlerInvokerbased on the fields contained in theSimpleEventHandlerInvoker.Builder.Will assert that at least one
EventMessageHandleris provided, and will throw anAxonConfigurationExceptionif this is not the case.- Parameters:
builder- theSimpleEventHandlerInvoker.Builderused to instantiate aSimpleEventHandlerInvokerinstance
-
-
Method Details
-
builder
public static <B extends SimpleEventHandlerInvoker.Builder<?>> SimpleEventHandlerInvoker.Builder<B> builder()Instantiate a Builder to be able to create aSimpleEventHandlerInvoker.The
ListenerInvocationErrorHandleris defaulted to aLoggingErrorHandlerand theSequencingPolicyto aSequentialPerAggregatePolicy. Providing at least one Event Handler is a hard requirement and as such should be provided.- Type Parameters:
B- An implementation ofSimpleEventHandlerInvoker.Builder.- Returns:
- A Builder to be able to create a
SimpleEventHandlerInvoker.
-
eventHandlers
Gets the list ofEventMessageHandlerdelegates in this invoker. These delegates are the end point of event handling.- Returns:
- The list of
EventMessageHandlerdelegates.
-
handle
Description copied from interface:EventHandlerInvokerHandle the givenmessagefor the givensegment.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.- Specified by:
handlein interfaceEventHandlerInvoker- Parameters:
message- The message to handlesegment- The segment for which to handle the message- Throws:
Exception- when an exception occurs while handling the message
-
sequencingPolicyMatchesSegment
-
sequenceIdentifier
-
invokeHandlers
- Throws:
Exception
-
canHandle
Description copied from interface:EventHandlerInvokerCheck whether or not this invoker has handlers that can handle the giveneventMessagefor a givensegment.- Specified by:
canHandlein interfaceEventHandlerInvoker- Parameters:
eventMessage- The message to be processedsegment- The segment for which the event handler should be invoked- Returns:
trueif the invoker has one or more handlers that can handle the given message,falseotherwise
-
canHandleType
Description copied from interface:EventHandlerInvokerCheck whether or not this invoker has handlers that can handle the givenpayloadType.- Specified by:
canHandleTypein interfaceEventHandlerInvoker- Parameters:
payloadType- The payloadType of the message to be processed- Returns:
trueif the invoker has one or more handlers that can handle the given message,falseotherwise
-
supportsReset
public boolean supportsReset()Description copied from interface:EventHandlerInvokerIndicates whether the handlers managed by this invoker support a reset.- Specified by:
supportsResetin interfaceEventHandlerInvoker- Returns:
trueif a reset is supported, otherwisefalse
-
performReset
public void performReset()Description copied from interface:EventHandlerInvokerPerforms any activities that are required to reset the state managed by handlers assigned to this invoker.- Specified by:
performResetin interfaceEventHandlerInvoker
-
performReset
public <R> void performReset(@Nullable R resetContext) Description copied from interface:EventHandlerInvokerPerforms any activities that are required to reset the state managed by handlers assigned to this invoker.- Specified by:
performResetin interfaceEventHandlerInvoker- Type Parameters:
R- the type of the providedresetContext- Parameters:
resetContext- aRused to support the reset operation
-
getListenerInvocationErrorHandler
Return theListenerInvocationErrorHandleras configured for thisEventHandlerInvoker.- Returns:
- the
ListenerInvocationErrorHandleras configured for thisEventHandlerInvoker
-
getSequencingPolicy
Return theSequencingPolicyas configured for thisEventHandlerInvoker.- Returns:
- the
SequencingPolicyas configured for thisEventHandlerInvoker
-