Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

On the principle of message queue

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

What is message queuing

You must be familiar with such a scene: after Xiao Wang went to M to order, the waiter gave him a number plate and asked him to wait at the counter table to pick up the meal. Everyone queued up to call the number in the order of the number they paid for. No matter how many people in the shop, it will not appear disorderly.

In the above scenario, the counter actually acts as a message queue (Message Queue). Producers such as Xiao Wang send the ordered message to the counter, that is, the message queue, and then take the meal from it and consume the message. It can be said that this is a complete trend of the message queue-the message is sent to the queue and successfully consumed by consumers. "message queue" is a container for storing messages in the process of message transmission. the main purpose of the queue is to provide routing and ensure message delivery. If the recipient is not available when the message is sent, message queuing retains the message until it can be successfully delivered.

Generally speaking, message queuing is an asynchronous way of inter-service communication, and it is an important component in distributed systems, which mainly solves the problems of application coupling, asynchronous messaging, traffic sharpening and so on, so as to achieve high performance, high availability, scalability and ultimate consistency architecture. The most frequently used message queues are ActiveMQ, RocketMQ, RabbitMQ, Kafka and so on.

The principle of distributed message Service

On the basis of message queue, a stable and reliable message queue service-distributed message service arises at the historic moment. Distributed message Service (Distributed Message Service, referred to as DMS) is a message middleware service based on highly available distributed cluster technology. It provides general queues, ordered queues, Kafka queues, ActiveMQ, RabbitMQ, compatible with HTTP, TCP, AMQP protocols, and provides asynchronous communication mechanisms with low latency and high concurrency for distributed applications. The schematic diagram of its production and consumption messages is shown in the following figure.

The message producer, who sends the message, also known as the message sender, sends the message to the specified message queue. The producer sends message M to the queue. Message M is redundantly distributed in the queue and there are multiple copies.

The party that consumes the message, also known as the message receiver, reads the message from the queue by invoking the consumer interface of the message service. Consumers consume messages from the queue and get message M. During the period when the consumer consumes message M, message M still stays in the queue, but message M cannot be consumed again by the consumption group within 30 seconds from the beginning of consumption. If the consumption is not completed by the consumer within these 30 seconds, DMS believes that message M is not consumed successfully and can continue to be consumed.

The consumer confirms that message M consumption is complete and message M will not be consumed by the consumer's consumer group. Message M remains in the queue and can be consumed by other consumer groups. Messages are retained in the queue for at least 72 hours (unless the queue is deleted) and will be deleted after 72 hours.

The above is the analysis of the principle of distributed message service, in the actual selection, we can consider different message queue products according to our own needs.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report