Class DeadLetteringEventHandlerInvoker
- All Implemented Interfaces:
EventHandlerInvoker,SequencedDeadLetterProcessor<EventMessage<?>>,MessageHandlerInterceptorSupport<EventMessage<?>>
EventHandlerInvoker utilizing a SequencedDeadLetterQueue to enqueue
events for which handling failed.
Will use an EnqueuePolicy to deduce whether failed event handling should result in an
enqueue operation. Subsequent events belonging to an
already contained "sequence identifier", according to the SequencingPolicy, are also enqueued. This ensures
event ordering is maintained in face of failures.
This dead lettering invoker provides several operations to process
dead letters it has enqueued. It will ensure the same set of Event Handling Components is invoked
as with regular event handling when processing a dead letter. These methods will try to process an entire sequence of
dead letters. Furthermore, these are exposed through the SequencedDeadLetterProcessor contract.
- Since:
- 4.6.0
- Author:
- Steven van Beelen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aDeadLetteringEventHandlerInvoker. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate a dead-letteringEventHandlerInvokerbased on the givenbuilder. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Instantiate a builder to construct aDeadLetteringEventHandlerInvoker.voidhandle(EventMessage<?> message, Segment segment) Handle the givenmessagefor the givensegment.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.booleanprocess(Predicate<DeadLetter<? extends EventMessage<?>>> sequenceFilter) Process a sequence ofdead lettersmatching the givensequenceFilter.registerHandlerInterceptor(MessageHandlerInterceptor<? super EventMessage<?>> interceptor) Register the givenhandlerInterceptor.voidsegmentReleased(Segment segment) This is a way for an event processor to communicate that a segment which was being processed is released.Methods inherited from class org.axonframework.eventhandling.SimpleEventHandlerInvoker
canHandle, canHandleType, eventHandlers, getListenerInvocationErrorHandler, getSequencingPolicy, invokeHandlers, sequenceIdentifier, sequencingPolicyMatchesSegment, supportsResetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.deadletter.SequencedDeadLetterProcessor
processAny
-
Constructor Details
-
DeadLetteringEventHandlerInvoker
Instantiate a dead-letteringEventHandlerInvokerbased on the givenbuilder. Uses aSequencedDeadLetterQueueto maintain and retrieve dead letters from.- Parameters:
builder- TheDeadLetteringEventHandlerInvoker.Builderused to instantiate aDeadLetteringEventHandlerInvokerinstance.
-
-
Method Details
-
builder
Instantiate a builder to construct aDeadLetteringEventHandlerInvoker.The
EnqueuePolicydefaults to returningDecisions.enqueue(Throwable)that truncates theThrowable.getMessage()size to1024characters when invoked for any dead letter, theListenerInvocationErrorHandleris defaulted to aPropagatingErrorHandler, theSequencingPolicyto aSequentialPerAggregatePolicy,allowResetdefaults tofalse,sequenceIdentifierCacheEnableddefaults tofalseandsequenceIdentifierCacheSizedefaults to1024. Providing at least one Event Handler, aSequencedDeadLetterQueue, and aTransactionManagerare hard requirements and as such should be provided.- Returns:
- A builder that can construct a
DeadLetteringEventHandlerInvoker.
-
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- Overrides:
handlein classSimpleEventHandlerInvoker- Parameters:
message- The message to handlesegment- The segment for which to handle the message- Throws:
Exception- when an exception occurs while handling the message
-
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- Overrides:
performResetin classSimpleEventHandlerInvoker
-
performReset
public <R> void performReset(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- Overrides:
performResetin classSimpleEventHandlerInvoker- Type Parameters:
R- the type of the providedresetContext- Parameters:
resetContext- aRused to support the reset operation
-
process
Description copied from interface:SequencedDeadLetterProcessorProcess a sequence ofdead lettersmatching the givensequenceFilter.Note that only a single matching sequence is processed! Furthermore, the
sequenceFilteris only invoked for the first letter of a sequence, as the first entry blocks the entire sequence.- Specified by:
processin interfaceSequencedDeadLetterProcessor<EventMessage<?>>- Parameters:
sequenceFilter- A filter for the firstdead letterentries of each sequence.- Returns:
trueif at least onedead letterwas processed successfully,falseotherwise.
-
registerHandlerInterceptor
public Registration registerHandlerInterceptor(@Nonnull MessageHandlerInterceptor<? super EventMessage<?>> interceptor) Description copied from interface:MessageHandlerInterceptorSupportRegister the givenhandlerInterceptor. After registration, the interceptor will be invoked for each handled Message on the messaging component that it was registered to, prior to invoking the message's handler.- Specified by:
registerHandlerInterceptorin interfaceMessageHandlerInterceptorSupport<EventMessage<?>>- Parameters:
interceptor- The interceptor to register- Returns:
- A Registration, which may be used to deregister the interceptor.
-
segmentReleased
Description copied from interface:EventHandlerInvokerThis is a way for an event processor to communicate that a segment which was being processed is released. This might be needed or required to free resources, are clean up state which is related to theSegment.- Specified by:
segmentReleasedin interfaceEventHandlerInvoker- Parameters:
segment- the segment which was released.
-