RABBITMQ is a complete, reusable enterprise messaging system based on AMQP. He follows the Mozilla Public License open source agreement.
MQ is all called the message queue, and Message Queuing (MQ) is an application-to-application communication method. Applications communicate by reading and writing messages to and from the queue (data for the application), without requiring a dedicated connection to link them. Message passing refers to the process of communicating between programs by sending data in a message, rather than by directly invoking each other, and directly invoking techniques such as remote procedure calls. Queuing refers to an application communicating through a queue. The use of queues removes the requirement that both the receiving and sending applications execute concurrently.
RABBITMQ Installation
Yum installation you can also use the source code to install
Installation configuration Epel Source
RPM-IVH http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Installing Erlang
# yum-y Install Erlang
Installing RABBITMQ
# yum-y Install Rabbitmq-server
Note: Service Rabbitmq-server start/stop
Install API
pip Install Pika or Easy_install Pika or source https://pypi.python.org/pypi/pika
To achieve the simplest queue communication
Send End
#!/usr/bin/env pythonImportPika Connection=Pika. Blockingconnection (Pika. Connectionparameters ('localhost')) Channel=Connection.channel ()#declaring a queueChannel.queue_declare (queue='Hello') #n RabbitMQ A message can never is sent directly to the queue, it always needs to go through an exchange.Channel.basic_publish (exchange="', Routing_key='Hello', Body='Hello world!')Print("[x] Sent ' Hello world! '") Connection.close ()
Receive End
#_*_coding:utf-8_*___author__='Alex Li'ImportPika Connection=Pika. Blockingconnection (Pika. Connectionparameters ('localhost')) Channel=Connection.channel ()#May ask why we declare the queue again? We had already declared it in our previous code.#we could avoid so if We were sure that the queue already exists. For example if send.py program#was run before. But we ' re not yet sure which program to run first. In such cases it ' s a good#practice to repeat declaring the queue in both programs.Channel.queue_declare (queue='Hello') defCallback (ch, method, properties, body):Print("[x] Received%r"%body) Channel.basic_consume (callback, queue='Hello', No_ack=True)Print('[*] waiting for messages. To exit Press CTRL + C') channel.start_consuming ()
Python Action RABBITMQ