From d15ee5b26bf9b79318e5f015d6258270585b8d1f Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Fri, 29 Sep 2017 20:20:25 +0200 Subject: [PATCH] Potential fix in actors. --- .../CQRS/Events/GetEventStoreSubscription.cs | 2 +- .../CQRS/Events/PollingSubscription.cs | 69 ++++++++++--------- .../Log/Internal/ConsoleLogProcessor.cs | 9 +-- .../Log/Internal/FileLogProcessor.cs | 9 +-- 4 files changed, 47 insertions(+), 42 deletions(-) diff --git a/src/Squidex.Infrastructure.GetEventStore/CQRS/Events/GetEventStoreSubscription.cs b/src/Squidex.Infrastructure.GetEventStore/CQRS/Events/GetEventStoreSubscription.cs index 2d5f3b843..d56c2ad7d 100644 --- a/src/Squidex.Infrastructure.GetEventStore/CQRS/Events/GetEventStoreSubscription.cs +++ b/src/Squidex.Infrastructure.GetEventStore/CQRS/Events/GetEventStoreSubscription.cs @@ -197,7 +197,7 @@ namespace Squidex.Infrastructure.CQRS.Events } catch (Exception ex) { - if (!(ex is ProjectionCommandConflictException)) + if (!ex.Is()) { throw; } diff --git a/src/Squidex.Infrastructure.MongoDb/CQRS/Events/PollingSubscription.cs b/src/Squidex.Infrastructure.MongoDb/CQRS/Events/PollingSubscription.cs index 416bd2691..ec121cdbe 100644 --- a/src/Squidex.Infrastructure.MongoDb/CQRS/Events/PollingSubscription.cs +++ b/src/Squidex.Infrastructure.MongoDb/CQRS/Events/PollingSubscription.cs @@ -69,55 +69,55 @@ namespace Squidex.Infrastructure.CQRS.Events switch (message) { case SubscribeMessage subscribe when parent == null: - { - parent = subscribe.Parent; - position = subscribe.Position; + { + parent = subscribe.Parent; + position = subscribe.Position; - streamFilter = subscribe.StreamFilter; - streamRegex = new Regex(streamFilter); + streamFilter = subscribe.StreamFilter; + streamRegex = new Regex(streamFilter); - pollSubscription = eventNotifier.Subscribe(streamName => + pollSubscription = eventNotifier.Subscribe(streamName => + { + if (streamRegex.IsMatch(streamName)) { - if (streamRegex.IsMatch(streamName)) - { - SendAsync(new StartPollMessage()).Forget(); - } - }); + SendAsync(new StartPollMessage()).Forget(); + } + }); - SendAsync(new StartPollMessage()).Forget(); + SendAsync(new StartPollMessage()).Forget(); - break; - } + break; + } case StartPollMessage poll when parent != null: + { + if (!isPolling) { - if (!isPolling) - { - isPolling = true; - - PollAsync().Forget(); - } + isPolling = true; - break; + PollAsync().Forget(); } + break; + } + case StopPollMessage poll when parent != null: - { - isPolling = false; + { + isPolling = false; - Task.Delay(5000).ContinueWith(t => SendAsync(new StartPollMessage())).Forget(); + Task.Delay(5000).ContinueWith(t => SendAsync(new StartPollMessage())).Forget(); - break; - } + break; + } case ReceiveEventMessage receiveEvent when parent != null: - { - await parent.SendAsync(receiveEvent); + { + await parent.SendAsync(receiveEvent); - position = receiveEvent.Event.EventPosition; + position = receiveEvent.Event.EventPosition; - break; - } + break; + } } } @@ -129,9 +129,12 @@ namespace Squidex.Infrastructure.CQRS.Events await SendAsync(new StopPollMessage()); } - catch (Exception ex) when (!(ex is OperationCanceledException)) + catch (Exception ex) { - await SendAsync(ex); + if (!ex.Is()) + { + await SendAsync(ex); + } } } } diff --git a/src/Squidex.Infrastructure/Log/Internal/ConsoleLogProcessor.cs b/src/Squidex.Infrastructure/Log/Internal/ConsoleLogProcessor.cs index 6d178c146..50465f29a 100644 --- a/src/Squidex.Infrastructure/Log/Internal/ConsoleLogProcessor.cs +++ b/src/Squidex.Infrastructure/Log/Internal/ConsoleLogProcessor.cs @@ -65,11 +65,12 @@ namespace Squidex.Infrastructure.Log.Internal { outputTask.Wait(1500); } - catch (TaskCanceledException) - { - } - catch (AggregateException ex) when (ex.InnerExceptions.Count == 1 && ex.InnerExceptions[0] is TaskCanceledException) + catch (Exception ex) { + if (!ex.Is()) + { + throw; + } } } } diff --git a/src/Squidex.Infrastructure/Log/Internal/FileLogProcessor.cs b/src/Squidex.Infrastructure/Log/Internal/FileLogProcessor.cs index e78892e39..47abd0d81 100644 --- a/src/Squidex.Infrastructure/Log/Internal/FileLogProcessor.cs +++ b/src/Squidex.Infrastructure/Log/Internal/FileLogProcessor.cs @@ -39,11 +39,12 @@ namespace Squidex.Infrastructure.Log.Internal { outputTask.Wait(1500); } - catch (TaskCanceledException) - { - } - catch (AggregateException ex) when (ex.InnerExceptions.Count == 1 && ex.InnerExceptions[0] is TaskCanceledException) + catch (Exception ex) { + if (!ex.Is()) + { + throw; + } } } }