Beispiel #1
0
        public void Subscribe <T, TH>()
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler <T>
        {
            var eventName = _subscriptionManager.GetEventKey <T>();

            DoInternalSubscription(eventName);
            _subscriptionManager.AddSubscription <T, TH>();
            StartBasicConsume();
        }
Beispiel #2
0
        public void Subscribe <TEvent, THandler>(string keyOverride = null)
            where TEvent : IIntegrationEvent
            where THandler : IIntegrationEventHandler <TEvent>
        {
            var eventName = string.IsNullOrWhiteSpace(keyOverride) ? _busSubscriptionManager.GetEventKey <TEvent>() : keyOverride;

            _logger.LogInformation($"Socket subscription manager: subscribed to: {eventName}");
            _busSubscriptionManager.AddSubscription <TEvent, THandler>(eventName);
            _subscriptionKeys.Add(eventName);
        }
        public void Subscribe <T, TH>()
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler <T>
        {
            var eventName = subscriptionManager.GetEventKey <T>();

            DoInternalSubscription(eventName);

            logger.LogTrace($"Subscribing for event {eventName}");

            subscriptionManager.AddSubscription <T, TH>();
            StartBasicConsume();
        }
        public void Subscribe <T, TH>()
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler <T>
        {
            var eventName = _subsManager.GetEventKey <T>();

            DoInternalSubscription(eventName);

            _logger.LogInformation("Subscribing to event {EventName} with {EventHandler}", eventName, typeof(TH).GetGenericTypeName());

            _subsManager.AddSubscription <T, TH>();
            StartBasicConsume();
        }
Beispiel #5
0
        public void Subscribe <T, TH>()
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler <T>
        {
            var eventName = _subscriptionManager.GetEventKey <T>();

            DoInternalSubscription(eventName);

            _logger.LogInformation($"Assinando o evento {eventName} com {typeof(TH).GetGenericTypeName()}");

            _subscriptionManager.AddSubscription <T, TH>();
            StartBasicConsume();
        }
Beispiel #6
0
        public void Subscribe <T, TH>()
            where T : IntegrationEvent
            where TH : IEventHandler
        {
            var eventName = _subManager.GetEventKey <T>();

            DoInternalSubscription(eventName);
            _subManager.AddSubscription <T, TH>();
        }
Beispiel #7
0
        public void Publish(IntegrationEvent @event)
        {
            if (!_connection.IsConnected)
            {
                if (!_connection.Connect())
                {
                    _logger.LogWarning($"Couldn't publish event {@event.Id}. No available connection was found.");
                    return;
                }
            }

            using (var ch = _connection.CreateModel())
            {
                DeclareExchange(ch);
                var msg = JsonSerializer.SerializeToUtf8Bytes(@event, @event.GetType());
                ch.BasicPublish(_exchangeName,
                                routingKey: _subscriptionManager.GetEventKey(@event.GetType()),
                                body: msg);
            }
        }
        public void Subscribe <T, TH>()
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler <T>
        {
            var eventName = _subsManager.GetEventKey <T>();

            var containsKey = _subsManager.HasSubscriptionsForEvent(eventName);

            if (!containsKey)
            {
                using (var channel = _persistentConnection.CreateModel())
                {
                    channel.QueueBind(queue: _queueName, exchange: _brokerName, routingKey: eventName, arguments: null);
                }
            }

            _subsManager.AddSubscription <T, TH>();
        }