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
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 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<?> |
eventHandlers()
Gets the list of Event Handler delegates.
|
ListenerInvocationErrorHandler |
getListenerInvocationErrorHandler() |
SequencingPolicy<? super EventMessage<?>> |
getSequencingPolicy() |
void |
handle(EventMessage<?> message,
Segment segment)
Handle the given
message for the given segment . |
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.
|
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 SimpleEventHandlerInvoker.Builder 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 thus should be accounted for.
SimpleEventHandlerInvoker
public List<?> eventHandlers()
public void handle(EventMessage<?> message, Segment segment) throws Exception
EventHandlerInvoker
message
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 EventHandlerInvoker
message
- The message to handlesegment
- The segment for which to handle the messageException
- when an exception occurs while handling the messagepublic boolean canHandle(EventMessage<?> eventMessage, Segment segment)
EventHandlerInvoker
eventMessage
for a given segment
.canHandle
in interface EventHandlerInvoker
eventMessage
- 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(Class<?> payloadType)
EventHandlerInvoker
payloadType
.canHandleType
in interface EventHandlerInvoker
payloadType
- 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()
EventHandlerInvoker
supportsReset
in interface EventHandlerInvoker
true
if a reset is supported, otherwise false
public void performReset()
EventHandlerInvoker
performReset
in interface EventHandlerInvoker
public <R> void performReset(R resetContext)
EventHandlerInvoker
performReset
in interface EventHandlerInvoker
R
- the type of the provided resetContext
resetContext
- a R
used to support the reset operationpublic ListenerInvocationErrorHandler getListenerInvocationErrorHandler()
public SequencingPolicy<? super EventMessage<?>> getSequencingPolicy()
Copyright © 2010–2020. All rights reserved.