예제 #1
0
 public async Task PublishAsync(object message, IDictionary <string, string>?headers = default)
 {
     try
     {
         var bus = _serviceBusFactory.GetServiceBus(message.GetType());
         await bus.Publish(message, headers);
     }
     catch (RebusApplicationException e)
     {
         // This error is thrown sometimes when the transport tries to add another "OnCommitted" handler to the current transaction.
         // It looks like it's some form of race condition, and only seems to happen when publishing a message to all receivers (including the current bus)
         // Might reach out to @mookid8000 to get a better understanding
         _logger.LogWarning(e, "Failed to publish message {@Message}. This happens when the transaction context used by Rebus has already been completed. Should be fine", message);
     }
 }
예제 #2
0
 private IBus GetBus(object message, string?queueName) => _serviceBusFactory.GetServiceBus(message.GetType(), queueName);
예제 #3
0
 public async Task PublishAsync(object message, IDictionary <string, string>?headers = default)
 {
     var bus = _serviceBusFactory.GetServiceBus(message.GetType());
     await bus.Publish(message, headers);
 }