I recently installed RabbitMQ to handle some message queuing needs at Readernaut and thought I’d share how everything came together. If you’d like to learn more about RabbitMQ please read this.
To use RabbitMQ with python you need py-amqplib because Rabbit uses the AMQP standard. To make amqplib a little easier to use I needed a simple script that did three things:
- Easy way to connect to RabbitMQ.
- Easy way to pull stuff out of the queue.
- Easy way to throw stuff into the queue.
This project which handles all this and much more but it’s a little too complex for what I’m doing. All I needed was something very small, straightforward, and EASY.
After staring at Carrot for a few days I decided to distill down what I needed into a single script I’m calling Flopsy. So here we go:
Step 1: Set global variables:
And there we go! Flopsy weighs in at under 80 lines of code and it can be found on Github. Most of the above will make a lot more sense after reading Rabbits and Warrens and investigating RabbitMQ.
I just realized, this isn’t at all Django specific so my title is a little misleading (changing). That said, you could most certainly use Flopsy with straight up Python :)