Joke Collection Website - Blessing messages - Awesome! Understanding message middleware -RabbitMQ

Awesome! Understanding message middleware -RabbitMQ

RabbitMQ was released in 2007, which is based on AMQP (Advanced Message Queuing Protocol). Message Queuing (MQ) is a communication method applied to applications, developed by Erlang (a language specially designed for high concurrency of big data), a reusable enterprise message system, and one of the most mainstream message middleware at present, with reliable and flexible routing and simple message clustering.

1. The message is data, which is added, deleted and checked. For example, adding, deleting and checking data in the employee management system.

2. Queue refers to data that enters at one end and exits at the other end, such as C# (Queue Data Structure).

1. Message queue means that one end receives messages and the other end sends messages.

2.RabbitMQ is a component that implements the concept of message queuing. With the idea of object-oriented, message queue is a class, and RabbitMQ is an example. Of course, not only RabbitMQ, such as ActiveMQ, RocketMQ, Kafka, but also Redis can realize message queuing.

1. In the common single architecture, the main process is that the user UI operation initiates an Http request >: server processing > then the server directly interacts with the database, and finally synchronously feeds back the user results.

2. In the microservice architecture, UI communicates with microservice, mainly through Http or gRPC.

problem analysis

In the above two cases, we found that UI requests are synchronous. Although the second architecture divides the whole service into different micro-services according to the business and corresponds to their respective databases, the problems when users communicate with micro-services are still unsolved. For example, the carrying capacity of the database can only handle the request of 10w. If the UI initiates a request of 50w in the case of high concurrency, the database can't bear it, which leads to the following problems.

The high concurrent request of 1. leads to system performance degradation and slow response, and at the same time increases the risk of database load.

2. The expansibility is not strong, and UI operation interaction relies heavily on business, which leads to the decline of user experience.

3. If the instantaneous traffic influx is huge, the server may hang up directly.

solution

RabbitMQ advantage

Shortcomings of RabbitMQ

1.ConnectionFactory is the connected manufacturing factory.

2.Connection is the socket link of RabbitMQ, which encapsulates some logic related to socket protocol.

3. Channel is the most important interface for us to handle RabbitMQ. Most of our business operations are completed in this interface, including defining queues, defining exchanges, binding queues and exchanges, and publishing messages.

4.Exchange (switch) We usually think that producers send messages to queues. In fact, producers send messages to exchanges, which route messages to one or more queues (or discard them). In RabbitMQ, Exchange I * * * has four strategies: fanout (sector), direct (direct), topic (topic) and headers.

Download RabbitMQ.

2. The running environment erlang

3. After the installation is completed, load the RabbitMQ management plug-in.

4. The installation is successfully connected to blogs.com/yuxl01/p/15978229.html, the management background of Rabbit MQ.