RabbitMQ AMQP (Advanced Message Queuing protocol)

Source: Internet
Author: User
Tags rabbitmq

Directory

    • RabbitMQ AMQP (Advanced Message Queuing protocol)
      • Message Queue Introduction
        • Concept
        • Basic composition
        • Scene and function
      • About AMQP
        • Model schema
        • Basic components
      • Amqp-rabbitmq
        • Brief introduction
        • Model
        • Characteristics
      • Reference
RabbitMQ AMQP (Advanced Message Queuing protocol)

The AMQP protocol is a Message Queuing protocol for message queue, and RabbitMQ is a messaging queue framework implemented based on the AMQP protocol.
Mastering the RABBITMQ, you must have an understanding of the AMQP protocol, in order to use the handy.
This article mainly introduces the basic concepts and architectures of AMQP protocol and RABBITMQ, and the detailed protocol introduction can refer to the official protocol document of AMQP. http://www.amqp.org/

Message Queue Introduction Concept

Message Queuing is an inter-process communication or a way of communicating between different threads of the same process. The sender and receiver of the message do not need to interact with the message queue at the same time. The message is saved in the queue until the recipient retrieves it.

Message Queuing is an important component in a distributed system.

Basic composition

Producer/publisher: producer, publisher of Message
Consumer/subscriber: Consumers of messages, subscribers
Queue: The cached person for the message
Message: Messaging Entity
Exchange: A switch for messages (not required)

Scene and function

1, decoupling: Through the introduction of Message Queuing middleware, reduce the complexity between the modules to achieve the purpose of decoupling.
2, Asynchronous: Message asynchronous delivery, through the introduction of Message Queuing, there is more flexible processing (active pull, service push), and can stack consumers to process messages in parallel.
3, current limit: a large-scale message generation at the same time, through the message middleware load balancing, to achieve the purpose of limiting the current.

About AMQP

AMQP is an application-layer standard advanced Message Queuing protocol that provides unified messaging services, an open standard for application-layer protocols designed for message-oriented middleware. The client and message middleware based on this protocol can deliver the message, which is not limited by the conditions of client/middleware and product, different development language, etc.

Model schema

AMQ Model:

Publisher and consumer remain connected to the server, and on the Publiser side, you only need to remain connected to exchange. When Publisher and consumer sign in, you need to specify that virtual Host,virtual host is like a C + + namespace, and the Exchange and Message queue are included within the scope of virtual host.

Message Delivery:

When Publisher has message delivery, it needs to carry exchange for the routingkey required for binding, and specifies that the message is posted to the specific Exchange name. This means that pushlisher is not directly associated with the message queue, and when it is delivered, it only needs to interact with the exchange side. Relevant delivery details and the persistence of the message, the confirmation mechanism of the message delivery, the operation of the message delivery transaction, and subsequent articles will have C code implementation.

Switch and queue bindings:

The switch and the queue are binding through the binding key, and the binding key is the matching rule that routes to the specific queue, and when a message enters exchange, Exchange binds to the routing key that the message carries. Routing key If the matching rule of the binding key is met, the message is posted to the queue with the binding rule. As you can see, routing key is associated with the message, and the binding key is associated with the queue, and exchange is the component that compares the two. There are four types of Exchange: Direct topic Fanout Header

Message consumption:

Consumer typically creates a specific queue and exchange and then binds it to consume different messages based on different business. Other details include consumer confirmations, QoS actions, Cancel, transactional operations, and more.

Basic components

Server
Connection
Channel
Virtual Host
Exchange
Message
Binding
Routing Key
Binding Key
Message Queue
Exchange Type (Direct topic fanout)
Producer-consumer
Publisher-subscriber (Topic Exchange Type)

Characteristics:
Persistent: persistent, requires simultaneous message, Exchange, queue support for persistence to achieve persistent operations
Confirm: Send Confirmation
Quality of Service: Consumers can specify QoS operations, Operation Prefetching, and bandwidth savings
Acknowledgements: Consumption Confirmation
Transaction: Transactional operations, support for the sending of a set of messages, and consumption, support rollback operations

AMQP-RABBITMQ Introduction

RABBITMQ is an open source message agent software (also known as message-oriented middleware) that implements the advanced Message Queuing Protocol (AMQP). RABBITMQ servers are written in Erlang, and clustering and failover are built on the framework of an open telecommunications platform. All major programming languages have client libraries that communicate with the agent interface.

Model

RABBITMQ Official website has 6 examples of use, other specific scenarios need to be based on their own business combination of trade-offs

1. Hello Word

P generates a Hello word message to Message Queuing, consumed by C, where the default Exchange

2. Work queues

P generates some messages to be delivered to the message queue, consumed by C1, C2, which uses the default Exchange (direct), C1 consumed messages that are not consumed by C2

3, Publish/subscribe

Publish subscription, use Fanout type of Exchange, p post message to X,x is the type of fanout, respectively, with two queue bindings, C1 and C2 consume the same message

4, Routing

Flexible routing, where direct-type exchange is used, on-demand binding, on-demand consumption

5, Topic

Topic type of exchange, combining messages with several feature sets, routing, matching rules more flexible

6. Rpc

Two message queues provide RPC functionality, the client posts the message, you need to set the server side message delivery required routing key, so that after the server received the message, processing finished, the return message to the reply queue corresponding exchange, Then it is consumed by the client from reply, and then the RPC call is realized.

But the official does not have the C + + implementation, later I will share the demo of the example I have implemented.

Characteristics

1, persistent, delivery confirmation, consumption confirmation, high availability
2. Flexible message routing, easy to use interface
3. Cluster deployment
4, management convenience, have management background
5, Erlang writing, high concurrency support

Reference

Https://en.wikipedia.org/wiki/Message_queue
http://www.amqp.org/
Http://www.rabbitmq.com/getstarted.html

RabbitMQ AMQP (Advanced Message Queuing protocol)

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.