RabbitMQ entry and several operating modes

1 Introduction

MQ full Message Queue, and the application for communication between applications. RabbitMQ Prepared using Erlang, implements AMQP (Advanced Message Queuing) protocol, cross-platform, supports all major operating systems and a variety of clients.
Compared with other types of RabbitMQ message queue, the biggest feature in ensuring considerable stand-alone throughput at the same time, the delay is very good.

2. Related Terms

Broker: popular talk is the server, the client receives the connection, the process of realization of AMQP protocol message queue and routing functions;
Virtual Host: Web Hosting, similar to the access control group. There may be a Virtual Host Exchange and a number of Queue, but the minimum granularity of access control is the Virtual Host;
Producer: Manufacturer message;
Consumer: the message consumer;
Queue: Queue message storage container;
the Message: producers and consumers need message data;
connection: a tcp connection;
Channel: a pipe connection, is connected (Broker) in tcp connection using the existing TCP connection for data transmission;
the exchange: switch, message routing, message transmission is not the producer sent directly to the queue but in the first-specified route and the route sent from the queues according to the routing key bound to the specified queue;
the binding: establishing a binding relationship between a queue and the routing of the container;
the routing key: routing key, primarily to find the queue.

3. Exchange of several operating modes

1. Direct-- routing mode

Any messages sent to the Direct Exchange will be forwarded to RouteKey specified Queue.
Exchange is not necessary to carry out this mode no binding (Binding) operation.
Requires a "RouteKey" message is transmitted, it can be simply understood as the name of the queue to be sent.
If the queue name RouteKey vhost specified does not exist, then the message will be discarded.

2. Fanout-- publish / subscribe model

Any messages sent to Fanout Exchange will be forwarded to all the Exchange Queue bindings (Binding) of.
This mode does not require RouteKey.
This model requires advance with the Exchange Queue bind, you can bind more than one Exchange Queue, Queue can be bound with a multiple Exchange.
If the received message is not bound to any Exchange Queue, then the message will be discarded.

3. Topic-- matching subscription model

Any messages sent to the Topic Exchange will be forwarded to all concerned RouteKey specified topics Queue.
Each queue has its theme is concerned, all messages are presented with a "Title" (RouteKey), Exchange will forward the message to a queue can all focus on the theme of fuzzy matching and RouteKey.
This model requires RouteKey, perhaps to bind the Exchange Queue advance.
During binding, the queue to provide a topic of concern.
. "#" Represents 0 or several keywords, "*" indicates a keyword.
Similarly, if Exchange can not find a match with RouteKey Queue, the message will be discarded.

4. headers

headers exchange primarily by matching the request message transmitted in the header, wherein the matching rule (x-match) is divided into all and any, all representatives must match all of the key-value pairs, any representative of a key as long as matching can be . headers exchange default matching rules (x-match) are any.

RabbitMQ operating mode

6 provides a working model in RabbitMQ official website: simple model, work queues mode, publish / subscribe model, routing patterns, themes, and RPC mode.

Simple mode and work queue mode

These two modes are very simple, involving only the producers, queues, consumers.
The producer is responsible for the production of news, send messages to the queue, consumers listen queue, the queue to consume news.
Work Queue mode is actually a simple pattern of a plurality of consumers.
When there are multiple consumers, the average consumer messages in the queue consumption.

Publish / Subscribe, Routing and themes

These three models will use the Exchange.
Producers do not directly interact with the queue, but to send a message to the switch, and then switch to send the message to the queue is bound to change the switch in consumer spending.
Commonly used types of switches three kinds: fanout, direct, topic.
fanout does not deal with routing keys, much like the subnet broadcast, the hosts in each subnet have received a copy of the message.
Publish / subscribe model refers to the use fanout exchange mode. fanout switch forwards the message type is the fastest.

direct routing key mode processing, routing keys need to match forward.
Route mode using a direct type switches.

topic: routing key and a matching pattern.
Themes are using the topic type of switch.

RPC mode

The client sends a request message to the server and then send a response message. In order to receive a response, we need to send a queue address 'callbacks' requests.

Guess you like

Origin www.cnblogs.com/xl2432/p/11026618.html