Python uses the Pika Library with RABBITMQ Summary, multiple notes and examples

Source: Internet
Author: User
Tags rabbitmq

Add by Zhj: Several articles from the author refer to a few articles in RABBITMQ's tutorials.

Original: http://www.01happy.com/python-pika-rabbitmq-summary/

This period of time to learn the next RABBITMQ, in the course of learning, found that the domestic use of Python Pika library RABBITMQ information is very few, the official website has this information, but all English. So the author combined with their own understanding, on this aspect of the content to write some examples, a total of seven notes, shared out.

The notes are sequential, and the code posted in the notes is actually running, and the Ubuntu 12.04,RABBITMQ version of the operating system is the 2.7.1,python version is 2.7.3.

Because the notes mentioned some nouns, although the name is not the same, but all are to express the same things, so it is necessary to explain the next, so as not to create doubts. It is mainly two nouns:

    • Producer literal translation for the generator, is to produce the message of the East, notes mentioned in the sender, the sender is a meaning. If the message is likened to a task, it can also be understood as a task-assigned person.
    • Consumer literal translation for consumers, is to receive the message of the East, notes mentioned in the receiver, the receiver is a meaning. If the message is likened to a task, it can also be understood as a worker.

1, Ubuntu installation RABBITMQ and Python use implementation

This article mainly records the process of installing the RABBITMQ service under Ubuntu and the process of installing the Python Pika Library, and demonstrates how one-way messages are sent.

2. Python uses RABBITMQ instance two, work queue

In the previous article, it shows how the message is sent in the case of multiple receiver ends.

3, Python use RABBITMQ instance three, switch

In the previous two examples, only one queue was used, and the message was sent sequentially to the receiving end bound to the queue. If you want to broadcast, use a switch, this article demonstrates how the switch works.

4. Python uses RABBITMQ instance four, routing key

The third piece of the message is broadcast out, all the receiving end will receive, if you want to accurately indicate the receiver of the message, you need to use the routing key, this article mainly demonstrates how the routing keys work.

5, Python using RABBITMQ instance five, routing key fuzzy matching

The fourth chapter of the routing key is precisely matched, sometimes with the need for fuzzy matching, this article mainly demonstrates the routing key fuzzy matching work mode.

6, Python uses RABBITMQ instance six, the remote result returns

All the previous five messages were sent out, and the receiver did not return the results to the sender. In some cases, the receiving end is required to process the received message and return it to the sending end, this article demonstrates how to handle this situation.

7, Python use RABBITMQ instance seven, the correlation number correlation ID

The previous article just sends a single message, the result of the return is naturally a message, but if multiple messages are issued at the same time, multiple results will be returned, how will the sent message and the returned result one by one correspond? This article demonstrates how the correlation ID works, which is used to solve this problem.

If you find a place where there is a mistake or if you have any suggestions, you are welcome to write a communication. My mailbox reference site to the right.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.