public virtual Task OnMessagePublishingAsync(MessagePublishingEventArgs e, CancellationToken cancellationToken = default(CancellationToken)) { return(Task.Run(async() => { await MessagePublishing?.Invoke(this, e); }, cancellationToken)); }
public virtual async Task PublishAsync <T>( T message, [CallerMemberName] string callerMemberName = "") where T : class, IMessage, new() { if (message == default(T)) { throw new ArgumentNullException(nameof(message)); } var topic = message.GetMessageTopicOrDefault <T>(); var json = JsonConvert.SerializeObject(message); var wrapper = new MessageWrapper(topic, json); var eventArgs = new MessagePublishingEventArgs(wrapper , callerMemberName); await Task.WhenAll(_publisherWrapper.SendAsync(wrapper), _configuration.OnMessagePublishingAsync(eventArgs)); }
public override Task OnMessagePublishingAsync(MessagePublishingEventArgs e, CancellationToken cancellationToken = default(CancellationToken)) { LatestMessagePublishingEventArgs = e; return(base.OnMessagePublishingAsync(e, cancellationToken)); }