The ListenerInvocationErrorHandler
is not supported for Event Handling Components that have dead-lettering enabled, @mbechto.
To be quite frank with you, I thought we added that to the dead-letter queue section of our documentation, but I see that’s not the case. Nonetheless, let me explain to you why we took this decision.
The ListenerInvocationErrorHandler
was our initial solution to give users the “power” to decide what to do with event handling failures. You could bubble up the exception, simply log the predicament, or retry right there, on the spot.
As time moved on, we figured a DLQ for Event Handling Components would be a great addition. Initially, we assumed we could simply make a new type of ListenerInvocationErrorHandler
and be done with it. This was, however, not possible.
The reason it’s not possible is because we want to ensure that if one event in a sequence fails, all subsequent events that belong to that sequence are also not handled. Hence, right before we invoke your Event Handlers, the referred to DeadLetteringEventHandlerInvoker
will first check if the given event is part of a dead-lettered sequence.
As the ListenerInvocationErrorHandler
only listens when something goes, it wouldn’t suffice for the sequenced dead-lettering behavior we were looking for.
Hence, we had to go one layer deeper, being the EventHandlerInvoker
, which constituted in the DeadLetteringEventHandlerInvoker
you’ve found too.
To circle back: as we require quite some control in the EventHandlerInvoker
to ensure the dead-lettering behavior is like it is, we decided that omitting the options given by the (suboptimal) ListenerInvocationErrorHandler
was the right choice.
Depending on what you want to achieve when an event fails, you’re best bet is to customize the EnqueuePolicy
. The EnqueuePolicy
will make the decision what to do with failed events, so would be your best bet to add additional behavior.
I hope all that clarifies thing sufficiently for you, @mbechto!