RabbitMQ related concepts

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

 RabbitMQ:

The concept: RabbitMQ is a producer and consumer model, mainly responsible for receiving, storing and forwarding messages.

Producer:

Producer: one message delivery.

  • Message generally comprises two sections:
  • Tags : used to describe the message, the name and routing keys such as a switch.
  • Message body : specific content of the message, JOSN format.

consumer

Consumer: Consumer is the party that receives the message.

  • RabbitMQ consumer connects to the server, to subscribe to the queue, the process of routing the message, the message will be discarded the label, the consumer will get the message body

Broker:

  • Messaging middleware service node

queue

  • Queue, RabbitMQ is an internal object that is used to store messages , RabbitMQ message will only store more consumers subscribe to the same queue in the queue, the message queue will be shared equally, to deal with multiple consumers, rather than each consumers receive all messages

Switch

  • The Exchange, the switch routes the message to one or more queues, if the route is not discarded

Binding: Binding :

  • RabbitMQ When the switch associated with the queue by a bond involves binding a binding key BindingKey when the producer sends a message to the switch, a need RoutingKey, and when BindingKey RoutingKey match, the message is routed to the corresponding queue.

Switch Type:

  • RabbitMQcy common types exchanger, fanout, Direct, Topic, headers, the AMQP protocol there is another protocol, there are two types: System and Custom

  • fanout: it will be sent to all the switch routes the message to all bound with the switch queue
  • Direct:    Direct routing type switch is also very simple rules, which routes the message to those BindingKey and RoutingKey exact match queue

  • Topic: Direct type of switch routing rules are exact match BindingKey and RoutingKey, but this way does not meet the strict match actual business needs, in many cases, topic type of switch is extended on the matching rules. RoutingKey a dot ".", Is a dot-delimited independent character called a word. BindingKey: There may be two special string "*" and "#" is used as fuzzy matching, which is used to match a word, "#" to match the multi-standard word
  • headers: headers does not depend on the type of switch keys to a routing rule matching information, but to match the content transmitted according to the message attributes in the headers. You specify a key-value pair and switches when bound to the queue, when the message is sent to the switch to be accessed RabbitMQ message headers (key-value pairs), whether the comparison key exact match, the match is routed to a queue.

Connection:  

  •   Both producers and consumers, and RabbitMQ Broker node needs to establish a connection , the connection is a TCP connection is Connection.
  • Once established TCP, the client can immediately create a AMQP channels, each channel is assigned a unique ID.

Channel Nobumichi:

  •     Connection is built on top of virtual connections

RabbitMQ can use the Connection to complete the task, why the introduction of the channel?

The following scene:

  •     An application has many threads need to consume from the RabbitMQ message, or the production of news, then the establishment of a number of Connection , which is a lot of TCP connections, if in case of peak usage , performance bottlenecks occur, RabbitMQ similar NIO practice, select TCP connection multiplexing.
  •      Each gripping a thread channel, the channel multiplexing of Connection TCP connection , while ensuring the privacy of each RabbitMQ thread 

Guess you like

Origin blog.csdn.net/qq_34579060/article/details/94608864