Consuming AMQP/RabbitMQ messages in Python is simple if you use Sparkplug. I read “Building RabbitMQ apps using Python“, and there’s just too much code in the monitor method and the separation of concerns aren’t very clear.

With Sparkplug, you create a configuration file, then define Consumer class to handle each message. As messages are pushed into the queue, Sparkplug will call your class and you decide how you want handle the message in the __call__ method. The great thing about this is that all the connection logic is removed from your code letting you concentrate on how you want to handle each message.

Now you can run your app using sparkplug --daemon consumer.ini. Configuration is boring, so I’ve left the consumer.ini out of the blog post and put it up on github instead.

Share and Enjoy:
  • del.icio.us
  • Reddit
  • Facebook
  • Identi.ca
  • TwitThis

Related posts:

  1. AMQP Kool-Aid Part 1.5: RabbitMQ Benchmark
  2. Taking a sip of the AMQP Kool-Aid Part I
  3. Erlang Exercise: N Processes in a Star
  4. Inversion of Control in Python

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Search