Exemplo n.º 1
0
 /// <summary>
 /// Event Publish to mq
 /// </summary>
 /// <param name="event"><see cref="IEvent"/></param>
 /// <returns></returns>
 internal async Task PublishEventAsync(IEvent @event, MQPublishType publishType = MQPublishType.Asynchronous)
 {
     if (publishType == MQPublishType.NotPublish)
     {
         return;
     }
     try
     {
         if (@event == null)
         {
             throw new ArgumentNullException("PublishEventAsync event cannot be empty");
         }
         if (this.PublishOptions != null)
         {
             await _mqPublisher.PublishAsync(@event, this.PublishOptions.Topic, this.PublishOptions.MQProvider, publishType);
         }
         var opt = this._internalConfiguration.GetEventPublishOptions(@event);
         if (opt != null)
         {
             await _mqPublisher.PublishAsync(@event, this.PublishOptions.Topic, this.PublishOptions.MQProvider, publishType);
         }
     }
     catch (Exception ex)
     {
         this.Logger.LogError(ex, $"Publish {@event.TypeCode}.V{@event.Version} event failed");
     }
 }
Exemplo n.º 2
0
        public static Task <bool> PublishAsync(this IMQPublisher publisher, IEvent @event, MQPublishType publishType = MQPublishType.Asynchronous)
        {
            var options = GetAttributeOptions(@event.GetType());

            if (options == null)
            {
                throw new Exception($"No eventPublishAttribute is marked for {@event.GetType().FullName} events");
            }
            return(publisher.PublishAsync(@event, options.Topic, options.MQProvider, publishType));
        }
Exemplo n.º 3
0
 public static async Task PublishAsync(this IMQPublisher publisher, IList <IEvent> events, string topic, string mqProviderName, MQPublishType publishType = MQPublishType.Asynchronous)
 {
     if (events == null || events.Count == 0)
     {
         return;
     }
     foreach (var e in events)
     {
         await publisher.PublishAsync(e, topic, mqProviderName, publishType);
     }
 }
Exemplo n.º 4
0
 public static async Task PublishAsync(this IMQPublisher publisher, IList <IEvent> events, MQPublishType publishType = MQPublishType.Asynchronous)
 {
     if (events == null)
     {
         return;
     }
     foreach (var e in events)
     {
         await publisher.PublishAsync(e, publishType);
     }
 }