Understand the next AMQP protocol

What AMQP protocol is?

AMQP protocol, called the Advanced Message Queuing Protocol, it can be understood as an accepted protocol specification, like http protocols, but this is the message queue for the AMQP protocol. This protocol specification so that it complied fully functional client application and a messaging middleware server interoperability possible.

Learn the basics under the AMQP protocol

  • Broker: accepting applications for information and dissemination of information.
  • Virtual hosts: Broker above in a divided more isolated environment, this environment can be more understood as Virtual hosts, just like using the same virtual machine, between each virtual machine has completed assembly, in each Virtual hosts users, such as switches and queue independently of each other, so easy to use in different business team with a Rabbit server service provided, it is possible to draw a line.
  • Connection: TCP connection between news producers and news consumers as well as Broker, if you want to disconnect, disconnect only the client, while the
    Broker is not disconnected unless the network fails or a Broker Services problem.
  • Channel: channel, if every time you access the message queue middleware to establish a TCP connection, then a large amount of system resources will be occupied, efficiency will be reduced, so AMQP provides a mechanism Channel, share the same TCP connection, and a TCP connection where you can have a lot of Channel. I assumed that if there are multiple threads to access the message queue middleware services, each thread usually has its own separate communications do Channel, and each will have its own Channel Channel ID, so that the client can recognize and Broker Channel each other, so between the Channel is completely isolated.
  • Exchange: switch, this is the first station Broker message arrives, since there is binding between the key and the Exchange Queues to determine matching rules both to send a message, so when Exchange based message routing keys and their type, to match binding rules, the message will be distributed to the corresponding Queues.
  • Queue: queue, messages reach the final station, where consumers get the message from the consumer to do.
  • Binding: it can be understood as a virtual connection is defined matching rules between the Exchange and Queues, only matching this rule will switch in a message is sent to the queue, but can not find a match if the message queue , then, the article according to the attribute of the message, the message is either discarded or returned there producers.

Exchange Type

Here the matching rules between the Exchange and Queues called key bindings.

Types of Explanation
direct (Direct) Routing key messages and key bindings to be exactly the same can be delivered to the queue
fanout (broadcast) No need to key bindings, and as long as there is bound to make this switch queue will receive the message, somewhat similar to the release - Subscribe
topic (theme) This type of switch required message routing keys and key bindings to fuzzy matching to distribute to. No to split each word, the # sign on behalf of more than one word matching, matching * number represents only a word
headers (header attributes) This type of switch is not based on the routing key, but on the message header attributes, only the message header associated with an attribute value of the same key, the message will be distributed to the appropriate queue
Default Switch If you do not specify the type of the above switch will use the default direct type, default key bindings while the queue name, so the message will be distributed to the queue and routing keys of the same name
Published 289 original articles · won praise 302 · views 50000 +

Guess you like

Origin blog.csdn.net/weixin_38106322/article/details/104862947