public class DeadLetteringEventHandlerInvoker extends SimpleEventHandlerInvoker implements SequencedDeadLetterProcessor<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.
Modifier and Type | Class and Description |
---|---|
static class |
DeadLetteringEventHandlerInvoker.Builder
Builder class to instantiate a
DeadLetteringEventHandlerInvoker . |
Modifier | Constructor and Description |
---|---|
protected |
DeadLetteringEventHandlerInvoker(DeadLetteringEventHandlerInvoker.Builder builder)
Instantiate a dead-lettering
EventHandlerInvoker based on the given builder . |
Modifier and Type | Method and Description |
---|---|
static DeadLetteringEventHandlerInvoker.Builder |
builder()
Instantiate a builder to construct a
DeadLetteringEventHandlerInvoker . |
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 |
process(Predicate<DeadLetter<? extends EventMessage<?>>> sequenceFilter)
Process a sequence of
dead letters matching the given sequenceFilter . |
canHandle, canHandleType, eventHandlers, getListenerInvocationErrorHandler, getSequencingPolicy, invokeHandlers, sequenceIdentifier, sequencingPolicyMatchesSegment, supportsReset
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
processAny
protected DeadLetteringEventHandlerInvoker(DeadLetteringEventHandlerInvoker.Builder builder)
EventHandlerInvoker
based on the given builder
. Uses a
SequencedDeadLetterQueue
to maintain and retrieve dead letters from.builder
- The DeadLetteringEventHandlerInvoker.Builder
used to instantiate a DeadLetteringEventHandlerInvoker
instance.public static DeadLetteringEventHandlerInvoker.Builder builder()
DeadLetteringEventHandlerInvoker
.
The EnqueuePolicy
defaults to returning Decisions.enqueue(Throwable)
when invoked, the
ListenerInvocationErrorHandler
is defaulted to a PropagatingErrorHandler
, the
SequencingPolicy
to a SequentialPerAggregatePolicy
, and allowReset
defaults to
false
. Providing at least one Event Handler, a SequencedDeadLetterQueue
, and a
TransactionManager
are hard requirements and as such should be provided.
DeadLetteringEventHandlerInvoker
.public void handle(@Nonnull EventMessage<?> message, @Nonnull 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
handle
in class SimpleEventHandlerInvoker
message
- The message to handlesegment
- The segment for which to handle the messageException
- when an exception occurs while handling the messagepublic void performReset()
EventHandlerInvoker
performReset
in interface EventHandlerInvoker
performReset
in class SimpleEventHandlerInvoker
public <R> void performReset(R resetContext)
EventHandlerInvoker
performReset
in interface EventHandlerInvoker
performReset
in class SimpleEventHandlerInvoker
R
- the type of the provided resetContext
resetContext
- a R
used to support the reset operationpublic boolean process(Predicate<DeadLetter<? extends EventMessage<?>>> sequenceFilter)
SequencedDeadLetterProcessor
dead letters
matching the given sequenceFilter
.
Note that only a single matching sequence is processed! Furthermore, the sequenceFilter
is
only invoked for the first letter of a sequence, as the first entry blocks the entire sequence.
process
in interface SequencedDeadLetterProcessor<EventMessage<?>>
sequenceFilter
- A filter for the first dead letter
entries of each sequence.true
if at least one dead letter
was processed successfully, false
otherwise.Copyright © 2010–2023. All rights reserved.