From b7ce4859b70d05778b5cf142ac2aa2b9a4cadb7f Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sun, 8 Oct 2017 20:30:06 +0200 Subject: [PATCH] Continue after failed --- .../CQRS/Events/Actors/EventConsumerActor.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Squidex.Infrastructure/CQRS/Events/Actors/EventConsumerActor.cs b/src/Squidex.Infrastructure/CQRS/Events/Actors/EventConsumerActor.cs index 12656e586..210435b27 100644 --- a/src/Squidex.Infrastructure/CQRS/Events/Actors/EventConsumerActor.cs +++ b/src/Squidex.Infrastructure/CQRS/Events/Actors/EventConsumerActor.cs @@ -31,6 +31,11 @@ namespace Squidex.Infrastructure.CQRS.Events.Actors public IEventConsumer EventConsumer { get; set; } } + private sealed class StopFailed + { + public Exception Exception { get; set; } + } + private abstract class SubscriptionMessage { public IEventSubscription Subscription { get; set; } @@ -86,7 +91,9 @@ namespace Squidex.Infrastructure.CQRS.Events.Actors .WriteProperty("state", "Failed") .WriteProperty("eventConsumer", eventConsumer.Name)); - return StopAsync(exception); + DispatchAsync(new StopFailed { Exception = exception }).Forget(); + + return TaskHelper.Done; } Task IEventSubscriber.OnEventAsync(IEventSubscription subscription, StoredEvent @event) @@ -128,6 +135,15 @@ namespace Squidex.Infrastructure.CQRS.Events.Actors break; } + case StopFailed stopFailed when isSetup && isRunning: + { + await StopAsync(stopFailed.Exception); + + isRunning = false; + + break; + } + case StopConsumerMessage stopConsumer when isSetup && isRunning: { await StopAsync();