-
-
Notifications
You must be signed in to change notification settings - Fork 295
Description
Description
I think I’ve found an unexpected behavior related to handler retries and failure policies.
We have a HandlerPolicy setup where, after all retries are exhausted, a new message should be sent.
This message is then handled by another handler, which updates the Publication status to failed (or blocked).
However, it seems that when the failure message is sent, the corresponding handler is invoked multiple times, instead of just once.
✅ Expected behavior
FailurePolicy should be executed:
only after all retries are exhausted
only once
❌ Actual behavior
The handler triggered by the failure message is invoked multiple times
In my test, it was called 6 times
🔍 Relevant code
public void Apply(
IReadOnlyList<HandlerChain> chains,
GenerationRules rules,
IServiceContainer container
)
{
var matchingChains = chains.Where(x =>
x.MessageType.BaseType == typeof(MyRequest)
);
foreach (var chain in matchingChains)
{
chain
.OnException(e =>
e is not ValidationException
)
.RetryWithCooldown(
1.Seconds(),
2.Seconds(),
4.Seconds(),
8.Seconds(),
16.Seconds()
)
.Then.Discard()
.And<MyFailurePolicy>();
}
}
🧪 Evidence
There is a test proving that the failure handler is invoked 6 times