MassTransit ISendEndpoint.Send method doesn’t throw exception when RabbitMQ is unreachable

Asked By: Anonymous

Having the following code snippet:

try 
{
  UpdateCommand updateCommand = new UpdateCommand
  {
    Name = "Update" 
  };

  await sendEndpoint.Send(updateCommand);
} 
catch (BrokerUnreachableException ex) 
{
}
catch (Exception ex)
{
}

When calling Send method and when there is no connection with RabbitMQ then exception is not being thrown. Is it supposed to work like this ?

I’ve tried to ConnectSendObserver to my ReceiveEndpoint like so:

ISendObserver sendObserver = new UpdateSendObserver();
cfg.ReceiveEndpoint(EventBusConstants.UpdateQueue, c => {
  c.ConfigureConsumer<UpdateCommandConsumer> (ctx);
  cfg.ConnectSendObserver(sendObserver);
});

But it doesn’t hit any of the PreSend, PostSend, SendFault methods when there is no connection with RabbitMQ.


Solution

Answered By: Anonymous

As explained in the GitHub Discussion, you can cancel the call to Send/Publish using a CancellationToken. The transport uses a retry policy if a connection to the broker is not available.

techinplanet staff

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno