private void DoInternalSubscription(string eventName)
        {
            var containsKey = _subsManager.HasSubscriptionsForEvent(eventName);

            if (!containsKey)
            {
                if (!_persistentConnection.IsConnected)
                {
                    _persistentConnection.TryConnect();
                }

                using (var channel = _persistentConnection.CreateModel())
                {
                    channel.QueueBind(queue: _queueName,
                                      exchange: BROKER_NAME,
                                      routingKey: eventName);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task ProcessEventAsync(string eventName, string payload)
        {
            if (_subsManager.HasSubscriptionsForEvent(eventName))
            {
                var subscriptions = _subsManager.GetHandlersForEvent(eventName);

                //Each Integration Event is a Unit of Work which could trigger many commands.
                using (var scope = _serviceProvider.CreateScope())
                {
                    scope.ServiceProvider.BeginUnitOfWork();

                    foreach (var subscription in subscriptions)
                    {
                        for (int i = 0; i < subscription.HandlerCount; i++)
                        {
                            await ProcessEventHandlerAsync(eventName, payload, subscription.HandlerType.FullName, i, scope.ServiceProvider).ConfigureAwait(false);
                        }
                    }

                    await scope.ServiceProvider.CompleteUnitOfWorkAsync();
                }
            }
        }