public async override Task PublishManyFromOutboxAsync(IEnumerable <OutgoingEventInfo> outgoingEvents, OutboxConfig outboxConfig) { var outgoingEventArray = outgoingEvents.ToArray(); var publisher = await _publisherPool.GetAsync( _options.TopicName, _options.ConnectionName); using var messageBatch = await publisher.CreateMessageBatchAsync(); foreach (var outgoingEvent in outgoingEventArray) { var message = new ServiceBusMessage(outgoingEvent.EventData) { Subject = outgoingEvent.EventName }; if (message.MessageId.IsNullOrWhiteSpace()) { message.MessageId = outgoingEvent.Id.ToString(); } if (!messageBatch.TryAddMessage(message)) { throw new AbpException( "The message is too large to fit in the batch. Set AbpEventBusBoxesOptions.OutboxWaitingEventMaxCount to reduce the number"); } } await publisher.SendMessagesAsync(messageBatch); }
protected virtual async Task PublishAsync(string eventName, object eventData) { var body = _serializer.Serialize(eventData); var message = new ServiceBusMessage(body) { Subject = eventName }; var publisher = await _publisherPool.GetAsync( _options.TopicName, _options.ConnectionName); await publisher.SendMessageAsync(message); }
protected virtual async Task PublishAsync( string eventName, byte[] body, Guid?eventId) { var message = new ServiceBusMessage(body) { Subject = eventName }; if (message.MessageId.IsNullOrWhiteSpace()) { message.MessageId = (eventId ?? GuidGenerator.Create()).ToString("N"); } var publisher = await _publisherPool.GetAsync( _options.TopicName, _options.ConnectionName); await publisher.SendMessageAsync(message); }