Eventuous / eventuous

Event Sourcing library for .NET
https://eventuous.dev
Apache License 2.0
447 stars 71 forks source link

Persistent subscriptions are not invoking the FailureHandler #370

Closed carlosgoias closed 1 month ago

carlosgoias commented 1 month ago

Describe the bug If you create persistent subscription with the configuration with FailureHandler settings, it's not being called, even using the ThrowOnError = true

To Reproduce Steps to reproduce the behavior:

private static Task RetryEventProcessingFailureHandler(
        EventStoreClient client,
        PersistentSubscription subscription,
        ResolvedEvent resolvedEvent,
        Exception exception
    )
{
    return subscription.Nack(PersistentSubscriptionNakEventAction.Skip, exception.Message, resolvedEvent);
}
...
services.AddSubscription<AllPersistentSubscription, AllPersistentSubscriptionOptions>(
    "PaymentIntegration",
    builder => builder.Configure(cfg => 
    {
        cfg.FailureHandler = RetryEventProcessingFailureHandler;
        cfg.ThrowOnError = true;
        cfg.EventFilter = StreamFilter.RegularExpression($"^{testId}#");
    }));

Expected behavior FailureHandler should be called.

Screenshots I suspect the problem is in this part PersistentSubscriptionBase, the line 198, is if(Options.ThrownOnError) throw exception, and never calling the line 202 with the failureHandler.

image

Desktop (please complete the following information): All

Smartphone (please complete the following information): All

Additional context Currently using 0.15.0-rc.2