RabbitMQ most complete history article

老规矩, This article is not RabbitMQcoded to explain, just introduce some excellent article in the learning
focuses not behave , tutorials go this way, you are not necessarily to him go, according to their own way, learning will be more efficient, online there are many tutorials, and today we got some good from that
RabbitMQ course, the first to say something about the basics of RabbitMQ, if you have help, to look, to prevent getting lost

The basic concept of RabbitMQ
Here Insert Picture DescriptionRabbitMQ github project address

RabbitMQ released in 2007, is one of the AMQP completed (Advanced Message Queuing Protocol) based on reusable enterprise messaging systems, is one of the most mainstream messaging middleware. A high-performance, robust and scalable known Erlang written, therefore inherited these. And RabbitMQ is a message broker and is an open source server queue.

AMQP : the Message Queuing Protocol Advanced, Advanced Message Queuing Protocol, is an open standard application layer protocol for message-oriented middleware design. Message middleware mainly for decoupling between the components, sender of the message without knowing the user's presence information, and vice versa.

surroundings

RabbitMQ can run on Erlang language supported platforms, including:

  • Solaris : Originally developed by Sun Microsystems Unix-like operating system called Oracle Solaris in after Sun's acquisition by Oracle.
  • BSD: Berkeley Software Distribution, abbreviated as BSD, also known as Berkeley Unix (Berkeley Unix), is the name of an operating system. Derived from Unix (like Unix), 1970's created by students at the University of California at Berkeley, Bill Joy (Bill Joy)
  • Linux: Is a free UNIX-like operating systems and open source. The operating system kernel created by Linus Torvalds for the first time in October 5, 1991
  • MacOSX : Is Apple's graphical user interface operating system specifically for the Macintosh computer, since 2002 pre-installed on all Mac computers.
  • Windows : Microsoft Windows (Microsoft Windows Chinese translation [4] [5]) is Microsoft's range of operating systems

Use RabbitMQ need:

ErLang Language Packs

Download: [http://www.erlang.org/downloads], double-click the .exe file to install just fine.

RabbitMQInstallation package
RabbitMQ Server official website Download

This article is focused on the following points:

  • A few basic concepts (Message, Publisher, Exchange, Binding, Queue, Channel, Consuer, Virtual host)
  • Several strategies of message distribution
  • What the hell is ACK

Basic Concepts
Message Queue (Message QUEUE)
first of all to a message queue classic map, can be divided into three roles: Producer, Queue, Consumer
Here Insert Picture Description

  • Queue: a container to carry the message, why is the queue instead of a stack of it? Mainly because most of the scenes, we all want the message to be FIFO, sequential
  • Producer: the producer, the message is generated, and continue to queue stopper role
  • Consumer: consumer, that is, continue to get messages from the queue role

See this model, if the container of the JDK have some knowledge, you can easily imagine the aid ArrayBlockingQueue or ListBlockingQueue can achieve a simple message queue (that is, we often say that the producer - consumer model)

Examples appreciated the message queue

In fact, in life, this model is used very much, like on the net purchase we will contact the courier can be said to be a typical message queue of the case:

Businesses continue to throw the goods courier companies (note not directly merchandise to the buyer), and the courier company will distribute goods in accordance with the corresponding geological buyers

The role of the above, the process for dismantling, can be mapped play

  • Product: Message, messaging, when delivered by the merchant to the courier company, the need for packaging (generally Producer entity production data message will also be encapsulated)
  • Business: Produer producer
  • Express: carrier Queue, the message
  • Buyer: Consumer Consumer

So how we should know what merchandise to the buyer when the corresponding courier company? The address on the package phone +

  • The same message queue also require a mapping rule for routing between Message and Consumer

RabbitMQ basic concepts

By comparing the above examples, the basic discovery message queue defined elements is too small, there is just a RabbitMQ can look at how to achieve specific message queue
Here Insert Picture Description

  • Message: message header comprising a message (i.e., the subsidiary configuration information) and the message body (i.e., the solid content of the message)
  • Publisher: producer, posted a message to the switch body
  • Exchange: switch, for receiving a message sent by the producer and to route the messages to the server queue
  • Binding: Binding for establishing relations to the Exchange and Queue, is our well-known matchmaker pairing
  • Queue: message queues, used to save the messages until sent to the consumer. It is a container for the message, the message is the end. A message can be put into one or more queues. Message has been in the queue inside, waiting for consumers to connect to the queue will remove it.
  • Connection: connection
  • Channel: channel, MQ and external dealings are through to the Channel, announced that the subscription queue or receive messages, these actions are completed by Channel; in short, the message queue by Channel into or out of the queue
  • Consumer: Consumers, get messages from the message queue body
  • Virtual Host: Web Hosting, represents a group of switches, message queues, and related objects. Web hosting is shared the same stand-alone server domain authentication and encryption environment. Is essentially a mini version of RabbitMQ server, with its own queue, switches, binding mechanisms and permissions for each vhost. AMQP is the basis of the concept of vhost must be specified at the time of connection, RabbitMQ is the default vhost /
  • Broker: Message Queue server entity

The above are some of the professional concepts, you can map how to express it on the front?

Exchange Type

Producers, the message is delivered to Exchange, and then by the Exchange routes the message to the corresponding Queue, for consumer spending, then the routing what way?

1. Direct Strategy

Here Insert Picture DescriptionKey message routing (routing key), and if the binding key Binding consistent switch will send a message to a corresponding queue

Simply put, that is the key route and queue name exact match

  • If a queue is bound to routing keys as in claim switch "dog"
  • Forward only routing key labeled "dog" news,
  • Not forwarded "dog.puppy", and does not deliver "dog.guard" etc.
  • It is an exact match, the unicast mode
    illustrated

Here Insert Picture DescriptionExchange and bind together two queues:

  • Q1 of bindingkey is orange
  • binding key Q2 is black and green.
  • When Producer publish key is orange time, exchange put it on Q1, if it is black or green will to Q2, the rest is discarded Message

2 .Fanout strategy

Here Insert Picture DescriptionCan also be seen from the chart, this strategy will ignore the so-called routing key, the message will be distributed to all Queue binding, more similar to our understanding of the broadcast mode

3. Topic Strategy

Here Insert Picture Description
matching the topic switch mode routing key attribute allocation message, the routing key and a pattern matching, the case needs to bind to a queue mode
can be understood as a direct advanced version of the policy, the policy is completely accurate direct match, the topic is to support the regular matching, meet certain specified criteria (such as at the beginning of the routing keys xxx), may be the key message distribution in the past

  • # Matches zero or more words
  • *Matching a word more, no less

The following examples a more intuitive

Here Insert Picture DescriptionProducer routing_key be set when sending messages,

  • binding key Q1 is ".orange."
  • Q2 is "... rabbit" and "lazy #.":
  • Test.orange.mm generate a message will be routed to Q1; and if it is test.orange can not be routed to Q1, Q1 is because the rules three words, the middle one of orange, does not satisfy this rule are invalid
  • Generating a test.qq.rabbit or may be distributed to lazy.qq Q2; i.e., the route of three key words, or the last one for the rabbit does not limit the number of words, a first main message is lazy, can be distributed over
  • If the produce is a test.orange.rabbit message, Q1 and Q2 are to meet

4. Headers strategy

This really used much, which is distributed according to the Message Message filter some header information, routing key attribute is ignored, and if the message header information Header information message match

5. Summary

The main message distribution strategies used by three, direct, route and sector, application scenarios, and the difference between a simple summary

a. Direct Exchange

Direct exact match mode for precise message distribution
b. Topic Exchange

Routing Key pattern matching, fuzzy matching Routing Key supported manner, more suitable polymeric message class
c. Fanout Exchange

Ignore Routing Key, the message will be assigned to all Queue, broadcast mode multiplexing scenario applies to messages

ACK

An important indicator of the message queue, when consumers get the message, how should I do about this news? Direct delete or wait for a suitable opportunity to delete? Or is simply not deleted, you can keep up?

In practical application scenario, after news of normal consumption, we hope that this news will not, but the process of consumption if there is a bug, you do not want to delete the message, so I fix this bug after, you can put this message again Drop me

  1. ack mechanism

After the Consumer has received the message, you must sign a return of the ack, a message indicating the success of the consumer, if it returns true, the consumer is successful, then the message will be deleted from the RabbitMQ queue; if it returns false, and the re-set into the team, then this message can be rerouted to come

Usually actual coding, the default is the automatic ACK if a higher degree of importance of the message, ACK we should set to active, after receiving the message, returns a corresponding independent ACK information

This is a more practical use of the content you can view articles


RabbitMQ is what we all already know about it, now, let's look at start sharing articles Tutorials

RabbitMQ explain the history of the most complete core knowledge

Article Address: https://blog.csdn.net/qq_42292373/article/details/97498198

Here Insert Picture Description

The most comprehensive and thorough guide RabbitMQ

Article Address: https://www.jianshu.com/p/3e76a144bebd

Here Insert Picture Description


RabbitMQ explain in detail the history of the most detailed

Article Address: https://blog.csdn.net/weixin_38305440/article/details/102810522

Here Insert Picture Description


RabbitMQ from entry to the master

Article Address: https://blog.csdn.net/hellozpc/article/details/81436980

Here Insert Picture Description


RabbitMQ teaching guides

Article bit biased theoretical, but the kind of meat, talked about the focus of
the article address: https://www.cnblogs.com/zhangxiaoliu/p/7524846.html

Here Insert Picture Description
Well, on the recommendation of the article here 谢谢大家

Published 58 original articles · won praise 136 · views 40000 +

Guess you like

Origin blog.csdn.net/qq_42897427/article/details/104581309