Switches in the RABBITMQ

Source: Internet
Author: User
Tags rabbitmq

The core concept of RABBITMQ (as shown): There are virtual hosts, switches, queues, bindings, and switches can be understood as routing programs with routing tables, that's all.      Each message has a property called route keys (routing key), which is a simple string. The latest version of RABBITMQ has four switch types, direct exchange, Fanout Exchange, Topic Exchange, Headers Exchange, respectively. Direct Exchange– Handle the routing key. A queue needs to be bound to the switch, requiring the message to exactly match a specific routing key. This is a complete match. If a queue is bound to the switch requiring the routing key "Dog", only the message labeled "Dog" is forwarded, the Dog.puppy is not forwarded, the Dog.guard is not forwarded, and only the dog is forwarded. fanout Exchange– The routing key is not processed. You simply have to bind the queue to the switch. A message sent to the switch is forwarded to all queues that are bound to the switch. Much like a subnet broadcast, each host in the network receives a copy of the message. Fanout switch Forwarding message is the fastest. Topic Exchange– Match the routing key with a pattern. At this point the queue needs to be bound to a pattern. The symbol "#" matches one or more words, and the symbol "*" matches no more than a few words. So "audit.#" is able to match to "Audit.irs.corporate", but "audit.*" matches only to "Audit.irs".

Headers Exchange – not yet carefully researched, copy the official introduction of the point.

A headers Exchange is designed-to-routing on multiple attributes that's more easily expressed as message headers tha n a routing key. Headers exchanges ignore the routing key attribute. Instead, the attributes used for routing is taken from the headers attribute. A message is considered matching if the value of the header equals the value specified upon binding.

It is the possible to bind a queue to a headers exchange using the than one header for matching. In this case, the broker needs one more piece of information from the application developer, namely, should it consider me Ssages with any of the headers matching, or all of them? The "X-match" binding argument is for. When the ' x-match ' argument is set to ' any ', just one matching header value is sufficient. Alternatively, setting ' X-match ' to ' all ' mandates that all the values must match.

Headers exchanges can is looked upon as "direct exchanges on steroids". Because they route based on header values, they can is used as direct exchanges where the routing key does not has to be a string; It could is an integer or a hash (dictionary) for example.

Messages are always sent first to the switch, routed to the queue by the exchange level, and the consumer gets the message from the queue! Reference: http://melin.iteye.com/blog/691265

Switches in RABBITMQ

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.