public void Subscribe <T, TH>() where T : IntegrationEvent where TH : IIntegrationEventHandler <T> { var eventName = _subscriptionsManager.GetEventKey <T>(); if (!_persistentConnection.IsConnected) { _persistentConnection.TryConnect(); } var hasSubs = _subscriptionsManager.HasSubscriptionsForEvent(eventName); if (!hasSubs) { using (var channel = _persistentConnection.CreateModel()) { channel.QueueBind(_queueName, exchange: _brokerName, routingKey: eventName); } } _logger.LogInformation("Subscribing to event {EventName} with {EventHandler}", eventName, typeof(TH).Name); _subscriptionsManager.AddSubscription <T, TH>(); StartBasicConsume(); }
public void Subscribe <T, TH>() where T : EventArguments where TH : IEventHandler <T> { var eventName = _subsManager.GetEventKey <T>(); DoInternalSubscription(eventName); _subsManager.AddSubscription <T, TH>(); }
public void Subscribe <TIntegrationEvent, TIntegrationEventHandler>() where TIntegrationEvent : IntegrationEvent where TIntegrationEventHandler : IIntegrationEventHandler <TIntegrationEvent> { var eventName = _subscriptionsManager.GetEventKey <TIntegrationEvent>(); DoInternalSubscription(eventName); _subscriptionsManager.AddSubscription <TIntegrationEvent, TIntegrationEventHandler>(); }
public void Subscribe <T, TH>() where T : DefaultEvent where TH : IEventHandler <T> { var eventName = subscriptionManager.GetEventKey <T>(); DoInternalSubscription(eventName); subscriptionManager.AddSubscription <T, TH>(); StartConsumer(); }
public void Subscribe <T, TH>() where T : Event where TH : IEventHandler <T> { var eventName = _subsManager.GetEventKey <T>(); DoInternalSubscription(eventName); _logger.LogInformation("Subscribing to event {EventName} with {EventHandler}", eventName, typeof(TH).Name); _subsManager.AddSubscription <T, TH>(); StartBasicConsume(); }
/// <summary> /// Subscribe to the Event type /// </summary> /// <param name="handler">Handler</param> /// <typeparam name="T">Event type</typeparam> /// <typeparam name="TH">Handler type</typeparam> /// <returns>Subscription guid</returns> public string Subscribe <T, TH>(Func <TH> handler) where T : IntegrationEvent where TH : IIntegrationEventHandler <T> { if (!_subscriptionsManager.HasEventTopic <T>()) { return(string.Empty); } var model = _integrationEventsRespository.SetModelAsync <T, TH>(); if (model == null) { throw new Exception($"Error on subscription to the integration event {typeof(T).Name}"); } return(_subscriptionsManager.AddSubscription <T, TH>(handler)); }
/// <summary> /// /// </summary> /// <typeparam name="TEvent"></typeparam> /// <typeparam name="TEventHandler"></typeparam> public void RegisterEventHandler <TEvent, TEventHandler>() where TEventHandler : IEventHandler <TEvent> { var eventName = subscriptionsManager.GetEventKey <TEvent>(); if (subscriptionsManager.HasSubscriptions(eventName)) { return; } if (!connection.IsConnected) { connection.TryConnect(); } using var model = connection.CreateModel(); model.QueueBind( queue: settings.QueueName, exchange: BROKER_NAME, routingKey: eventName); subscriptionsManager.AddSubscription <TEvent, TEventHandler>(); }
/// <summary> /// /// </summary> /// <typeparam name="TEvent"></typeparam> /// <typeparam name="TEventHandler"></typeparam> public void RegisterEventHandler <TEvent, TEventHandler>() where TEventHandler : IEventHandler <TEvent> { subscriptionsManager.AddSubscription <TEvent, TEventHandler>(); }