我已经在 Windows Server 2012 64 位上安装了 RabbitMQ。
我测试了具有大量数据的发布和消费部分,一切都很好,我面临的唯一问题是 RabbitMQServer 重新启动后队列中的消息丢失。
我正在使用RabbitMQ的VB.Net SDK。
我将 Queue Declare 的 “Durable”
属性设置为 true,并将 DeliveryMode BasicQueueProperties 设置为“2”
以使消息持久化。但在我的服务器重新启动后,消息仍然丢失。
我该如何克服这个问题?
最佳答案
https://www.rabbitmq.com/tutorials/tutorial-two-dotnet.html
在 RabbitMQ 上的消息持久性页面中,它解释得很好:
At this point we're sure that the task_queue queue won't be lost even if RabbitMQ restarts. Now we need to mark our messages as persistent - by setting IBasicProperties.Persistent to true.
var properties = channel.CreateBasicProperties(); properties.Persistent = true;
Note on message persistence
Marking messages as persistent doesn't fully guarantee that a message won't be lost. Although it tells RabbitMQ to save the message to disk, there is still a short time window when RabbitMQ has accepted a message and hasn't saved it yet. Also, RabbitMQ doesn't do fsync(2) for every message -- it may be just saved to cache and not really written to the disk. The persistence guarantees aren't strong, but it's more than enough for our simple task queue. If you need a stronger guarantee then you can use publisher confirms.
关于vb.net - 重启后rabbitmq队列清空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29520437/