Пример #1
0
 public Task <bool> Publish(IEvent @event)
 {
     try
     {
         var message = new EventPublishMessage()
         {
             Event    = @event,
             TypeCode = @event.TypeCode
         };
         return(this._publisher.Publish(_options.Topic, message));
     }
     catch (Exception ex)
     {
         this._logger.LogError(ex, @event.ToString());
         return(Task.FromResult(false));
     }
 }
Пример #2
0
 public Task <bool> Publish(IList <IEvent> events)
 {
     try
     {
         List <EventPublishMessage> messages = new List <EventPublishMessage>();
         foreach (var e in events)
         {
             var message = new EventPublishMessage()
             {
                 Event    = e,
                 TypeCode = e.TypeCode
             };
             messages.Add(message);
         }
         return(this._publisher.Publish(_options.Topic, messages));
     }
     catch (Exception ex)
     {
         this._logger.LogError(ex, "A lot of publish errors");
         return(Task.FromResult(false));
     }
 }