Example #1
0
        async Task ActionBlockCallback([NotNull] SendMessageRequest request)
        {
            try
            {
                // Process unsubscribe requests
                _subscriptionProvider.ApplyPendingSubscriptionCancellations();

                // Process subscribe requests
                _subscriptionProvider.ApplyPendingSubscriptions();

                var result = true;

                foreach (var subscription in _subscriptionProvider.GetSubscriptions())
                {
                    var processResult = await ProcessSubscriptionAsync(subscription, request).ConfigureAwait(false);

                    if (!processResult)
                    {
                        result = false;
                        break;
                    }
                }

                request.OnSendComplete(result);
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception e)
            {
                if (_options.EnableInternalLogging)
                {
                    _logger.LogError(e, "InMemory Event bus: Unexpected error occured while publishing event message (processing subscriptions).");
                }

                request.OnSendComplete(false);
            }
        }