Rabbitmq 由于连接中断导致基本发布失败后重新发送消息的正确方式
我使用C#client 有时,在我使用BasicPublish发送消息之前,连接会丢失。当这种情况发生时,我希望重试发送消息,最好是在连接恢复后Rabbitmq 由于连接中断导致基本发布失败后重新发送消息的正确方式,rabbitmq,Rabbitmq,我使用C#client 有时,在我使用BasicPublish发送消息之前,连接会丢失。当这种情况发生时,我希望重试发送消息,最好是在连接恢复后 try { channel.BasicPublish("exchange", "routingKey", basicProperties, body); } catch (OperationInterruptedException ex) { // Connection lost! How to
try
{
channel.BasicPublish("exchange", "routingKey", basicProperties, body);
}
catch (OperationInterruptedException ex)
{
// Connection lost! How to try again sending the message when the connection is up again?
}
这样做最常见的模式是什么?我已经阅读了很多文档,我知道publisher确认机制允许您订阅BasicAcks和BasicNack,但在连接中断的情况下不会发送BasicNack事件。因此,我可以知道消息何时成功发送,但不能知道在断开连接的情况下消息何时失败
你有什么建议吗?C#客户端库中是否有自动执行此操作的机制?我错过了什么
谢谢