RABBITMQ and AMQP Protocol detailed

Source: Internet
Author: User


1. History of Message Queuing
Knowing the ins and outs of one thing will not be mysterious to it. Let's take a look at the development history of the message queue, the technology.

The message queue has a long history of the 80 's, the first in financial transactions, Goldman Sachs and other companies to adopt Teknekron Company's products, then the Message Queuing software is called: The Information Bus (TIB). TIB was adopted by telecoms and communications companies, and Reuters acquired Teknekron Corp. IBM developed the MQSeries, and Microsoft developed the Microsoft Message Queue (MSMQ). The problem with these commercial MQ vendors is that they are vendor-locked and expensive. In 2001, Java Message queuing tried to solve the problem of locking and interactivity, but it was even more troublesome for the application.

So in 2004, JPMorgan Chase and Imatrix began the development of the Advanced Message Queuing Protocol (AMQP) open standards. 2006, the AMQP specification was released. In 2007, Rabbit Technology Inc. RABBITMQ 1.0, developed based on the AMQP Standard, was released.

Currently, the latest version of RABBITMQ is 3.5.7, based on AMQP 0-9-1.

RABBITMQ is developed using Erlang language. The Erlang language is designed by Ericson and is used extensively in the telecommunications field for the development of a language for concurrent and distribution systems. OTP (Open Telecom Platform), as part of the Erlang language, contains a number of Erlang-based middleware/libraries/tools such as MNESIA/SASL, which greatly facilitates the development of Erlang applications. The OTP is similar to the many module in the Python language, which enables users to develop applications conveniently.

2. Basic concepts in AMQP messaging

  • Broker: An app that receives and distributes messages, RabbitMQ server is message Broker.
  • Virtual Host: Designed for multitenant and security reasons, the basic components of AMQP are partitioned into a virtual grouping, similar to the namespace concept in the network. When many different users use the same RABBITMQ Server service, you can divide multiple vhost, each user creates exchange/queue in their own vhost, and so on .
  • Connection: TCP connection between Publisher/consumer and broker. The disconnected operation occurs only on the client side, and the broker does not disconnect unless there is a network failure or a problem with the broker service.
  • Channel: If a connection is established for each access RABBITMQ, the overhead of establishing a TCP connection when the message volume is large will be huge and less efficient. The channel is a logical connection established within the connection, and if the application supports multiple threads, usually each thread creates a separate channel for communication, the AMQP method contains the channel ID to help the client and the message The broker identifies the channel, so the channel is completely isolated. The channel as a lightweight connection greatly reduces the overhead of the operating system to establish TCP connection.
  • Exchange: Message arrives at the broker's first stop, distributing the message to the queue according to the distribution rules, matching the routing key in the query table. Common types are: direct (point-to-point), topic (Publish-subscribe) and fanout (multicast).
  • Queue: The message was eventually sent here to wait for consumer to take it away. A message can be copied to multiple queues at the same time.
  • binding: A virtual connection between Exchange and the queue, which can contain routing key. The binding information is saved to the query table in exchange for the distribution basis of the message.

3. Typical "Production/consumption" message model

The producer sends a message to broker Server (RabbitMQ). Inside the broker, the user creates the Exchange/queue and ties the two together through the binding rules. Exchange distributes messages, which differ according to the different distribution policies of type/binding. The message finally comes to the queue, waiting for the consumer to take it.

4. Exchange Type
There are several types of exchange, the most common being direct/fanout/topic three types.


If the "Routing key" in the message is consistent with the "binding key" in the binding, Direct Exchange sends the message to the corresponding queue.


Each message sent to Fanout type Exchange is divided into all bound queue.


Depending on the routing key, and the wildcard rules, Topic Exchange is distributed to the target queue.

Routing key can contain two wildcard characters, similar to regular expressions:


It is also recommended for students who want to learn about RABBITMQ a website, http://tryrabbitmq.com, which offers an online RABBITMQ simulator that can help understand exchange/queue/binding concepts.

At this point, we have made a complete introduction to the development of Message Queuing, the generation of RABBITMQ, and the important concepts in the AMQP protocol.

RABBITMQ and AMQP Protocol detailed

Related Article

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.

Tags Index: