domingo, 9 de agosto de 2015

Messaging with RabbitMQ + Python

Today I'm gonna write about messaging with RabbitMQ and python. I've worked in some projects using ActiveMQ interacting with Java, C# and F#, but there are a lot of examples on the web about the interaction between Java and Active MQ. With the intent of making something different, I decided to make this example using RabbitMQ with Python. That's an alternative for who wants to use messaging with python. You can also interact python with ActiveMQ, but that's a subject for a future post, maybe ;).

Installation


First of all, let's install RabbitMQ. In my case, I use Ubuntu 15.04, here are the steps for installing RabbitMQ:
  • sudo apt-get install rabbitmq-server
Yeah, simple like that!! Here is the download/installation steps for other operating systems.

On python side, I've used a lib called Pika. I've made the installation using pip, here is the command:
  • pip install pika

The code

The example shown below is divided into three parts: sender, receiver and main program exploring the basic features in a simple and clear code.

Sender:


Receiver:


Main:


















Concluding, the intent of this post was to show a way of working with messaging and python. This example was simple, but it's a good start point for who wants to play with messaging and python. Particularly I love python programming, it was a nice experience and I pretend to evolve more this example, showing advanced features and more fun things.

You can check the code on my github: https://github.com/marcelocure/sandbox/tree/master/python/python_messaging

Nenhum comentário:

Postar um comentário