且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何从RabbitMQ获取旧消息?

更新时间:2023-02-16 14:11:05

每次启动使用者时,您都会在创建新队列!因此,当您重新启动使用者时,新队列将获得新消息,但没有以前的消息.

You're making a new queue each time you start the consumer! So when you restart the consumer, the new queue gets new messages, but doesn't have previous ones.

执行此操作:

q    = ch.queue("myqueue",durable: true)

代替此:

q    = ch.queue("")

然后,一旦重新启动使用者,它将立即以最快的速度获取所有备份的消息.

Then, as soon as you restart the consumer, it will immediately get all backed-up messages as fast as it can.