当前位置:网站首页>What is a message queue

What is a message queue

2022-04-23 19:15:00 Sound God

“ Message queue ” It's a container that holds messages during their transmission .

Introduction to message queuing

Message queue ( English :Message queue) It is a kind of communication between processes or between different threads of the same process , The storage column of software is used to process a series of inputs , It's usually from users .

Message queuing provides asynchronous communication protocol , The records in each column contain detailed data , Including when it happened , Type of input device , And specific input parameters , in other words : The sender and receiver of the message do not need to interact with the message queue at the same time . The message is kept in the queue , Until the receiver gets it back .

“ news ” A unit of data transmitted between two computers . The message can be very simple , For example, only text strings ; It can be more complicated , May contain embedded objects .

The message is sent to the queue .“ Message queue ” It's a container that holds messages during their transmission . The message queue manager acts as an intermediary when relaying messages from its source to its destination . The main purpose of queues is to provide routing and ensure the delivery of messages ; If the recipient is not available when sending a message , Message queues keep messages , Until it can be successfully delivered .

Features of message queuing

1. asynchronous : The message queue itself is asynchronous , No need to wait for a response .( Asynchronous features of message queues , It also creates a disadvantage , That is, the receiver must poll the message queue , To receive the latest news )

2. decoupling : Message queuing reduces the coupling between services , Different services can communicate through message queues , Instead of caring about each other's implementation details , Just define the format of the message .

3. radio broadcast : One of the basic functions of message queuing is to broadcast . If there is no message queue , Whenever a new business party accesses , We all need a joint debugging of the new interface . With message queuing , We just need to care if the message has reached the queue , As for who wants to subscribe , It's downstream , Undoubtedly, it greatly reduces the workload of development and joint commissioning .

4. Peak shaving and flow control
When there is a gap between the processing capacity of upstream and downstream systems , Make a general use of message queuing ” carrier ”. When the downstream has the ability to handle , Re distribution and processing .

Message queuing mode

At present, message queuing is mainly used 2 Patterns , Respectively “ Point to point mode ” and “ Release / A subscription model ”.

Point to point mode :

When a message is processed by a messenger , This message will be locked or removed on the queue and other consumers will not be able to process it . If a consumer fails to process a message , The message system usually puts the message back on the queue , So that other consumers can continue to deal with .

Release / A subscription model :

A single message can be acquired and processed concurrently by multiple subscribers . Generally speaking , There are two types of subscriptions .

1. temporary (ephemeral) subscribe , This subscription exists only when the consumer is up and running . Once the consumer exits , The corresponding subscription and messages that have not yet been processed will be lost .

2. persistent (durable) subscribe , This kind of subscription will always exist , Unless you take the initiative to delete . After the consumer exits , The messaging system will continue to maintain the subscription , And subsequent messages can be processed .

Commonly used message queue middleware

Kafka:

Apache Kafka It was originally made by LinkedIn Based on the unique design, the company implements a distributed submission log system ( a distributed commit log), Then become Apache Part of the project . The killer mace of big data , When it comes to message transmission in the field of big data , You can't get around it Kafka, This message middleware for big data , With its millions TPS We have a reputation for throughput , Quickly become the darling of big data , In data collection 、 transmission 、 The storage process plays an important role .

RabbitMQ:

RabbitMQ 2007 Released in , It's using Erlang Open source message queuing system developed by language , be based on AMQP Protocol to implement .AMQP The main feature is message oriented 、 queue 、 route ( Including point-to-point and release / subscribe )、 reliability 、 Security .AMQP Protocols are more used in enterprise systems , For data consistency 、 Scenarios requiring high stability and reliability , The performance and throughput requirements are still second .

RocketMQ:

Alibaba's open source message middleware , It's pure Java Development , High throughput 、 High availability 、 Features suitable for large-scale distributed system applications .RocketMQ Thought originated from Kafka, But it is not Kafka One of the Copy, It optimizes the reliable transmission and transaction of messages , At present, Alibaba group is widely used in transactions 、 Recharge 、 Flow calculation 、 Message push 、 Log streaming 、binglog Distribution and other scenarios .

ActiveMQ:

yes Apache Produce , One of the most popular , Powerful open source message bus . The official community is right now ActiveMQ 5.x Less maintenance , Less used in large-scale throughput scenarios .

版权声明
本文为[Sound God]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231913518436.html