Exemplo n.º 1
0
        public Task Publish <TEvent>(TEvent eventToPublish) where TEvent : IEvent
        {
            var subscribers = GetEligibleSubscribers <TEvent>();

            foreach (var eventHandler in subscribers)
            {
                eventHandler.HandleAsync(eventToPublish);
            }

            if (eventToPublish is IIntegrationEvent)
            {
                //  _externalMessages.Enqueue((IIntegrationEvent)eventToPublish);
                _enterpriseServiceBus.Publish((IIntegrationEvent)eventToPublish);
            }
            return(Task.CompletedTask);
        }
 private void PublishExternalMessages()
 {
     while (externalMessages.Any())
     {
         //TODO : Handle Exception
         var message = externalMessages.Dequeue();
         enterpriseServiceBus.Publish(message);
     }
 }