Using acknowledgement
In order to properly handle the case where a web server that we need to fetch data from goes down, we need to understand one thing. Once a worker fetches a message from RabbitMQ with a no_ack model, which we have been using so far (feel free to reread the code if this is the first time you've seen it), and if it fails, it will take the message with it.
Unless it will only take the message with it once it is really finished working with it. For this to work, we need to use the acknowledgement model from RabbitMQ.
Each worker, once really done with a message, must acknowledge the message back to RabbitMQ, and only then will RabbitMQ sign the message off and remove it from the queue.
Let's update our worker code to acknowledge ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access