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

Detailed explanation of message Middleware MQ

2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

1 introduction of message middleware

In general, we think that message middleware refers to the middleware that supports and guarantees synchronous / asynchronous sending and receiving messages between distributed applications. Message is the basic information unit for data exchange between distributed applications, and the communication interface between distributed applications is provided by message middleware. Among them, asynchronous mode means that when sending a message, the sender does not need to know the status of the receiver, let alone wait for a reply from the receiver, and the receiver does not need to know the current state of the sender when receiving the message, let alone synchronous message processing, the connection between them is completely loosely coupled, and the communication is non-blocking. This asynchronous communication mode is guaranteed by message queuing and its service mechanism in message middleware. Generally speaking, the services with high real-time requirements are processed synchronously, and the services with low real-time requirements are processed asynchronously.

Message middleware has been widely used in all kinds of distributed application systems. message middleware begins to change to publish / subscribe architecture and becomes a core mechanism of enterprise application integration middleware. Message middleware based on publish / subscribe architecture is usually called publish / subscribe message middleware or message broker. At present, typical message middleware includes IBM WebSphere MQSeries, Ali's RocketMQ, Kafka and so on.

Message middleware is a container that stores information during the transmission of a message. Message middleware acts as a middleman when relaying messages from its source to its target. The main purpose of queuing 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, and of course, message queuing holds messages for a time.

2 the characteristics of message middleware 2.1 adopt asynchronous processing mode

The message sender can send a message without waiting for a response. The message sender sends the message to a virtual channel (topic or queue), and the message receiver subscribes to or listens to that channel. A message may eventually be forwarded to one or more message receivers, none of whom need to respond synchronously to the message sender. The whole process is asynchronous.

2.2 the relationship between application and application call is loosely coupled.

It is mainly reflected in the following two points:

(1) the sender and receiver do not need to know each other, only need to confirm the message

(2) the sender and receiver do not have to be online at the same time.

For example, in order to ensure the final consistency of the data, the online trading system will put the payment results into the message middleware to inform the order system to modify the payment status after the completion of the payment system. The two systems are decoupled by message middleware.

3 message delivery service model

The messaging service model is shown in the following figure

4 Transmission mode of message middleware 4.1 point-to-point model

The point-to-point model is used for point-to-point communication between message producers and message consumers. The message producer sends the message to a specific consumer identified by a name. This name is actually stored in a queue (Queue) in the consumer service before the message is delivered to the consumer. Queue messages can be in memory or persistent to ensure that messages can still be delivered in the event of a message service failure.

The traditional point-to-point message middleware is usually composed of message queue service, message delivery service, message queue and message application program interface (API). Its typical structure is shown in the following figure.

Features:

(1) each message uses only one consumer.

(2) the sender and receiver have no time dependence.

(3) the recipient confirms that the message has been accepted and processed successfully.

The schematic diagram is as follows:

4.2 publish-subscribe Model (Pub/Sub)

The publisher / subscriber model supports the production of messages to a specific message topic. 0 or more subscribers may be interested in receiving messages from specific message topics. In this model, publishers and subscribers do not know each other. This model is like an anonymous bulletin board. This pattern is outlined as follows: multiple consumers can get messages, and there is a time dependence between publishers and subscribers. The publisher needs to establish a subscription in order to be able to subscribe to consumers. Subscribers must remain active and receive messages unless the subscriber has established a persistent subscription. In this case, messages posted when the subscriber is not connected will be republished when the subscriber reconnects. As shown in the following figure:

Publish / subscribe model features

(1) each message can have multiple subscribers

(2) the client can receive the message only after subscription.

(3) persistent and non-persistent subscriptions

Note:

(1) publishers and subscribers have time dependence

Only by establishing a subscription relationship can the recipient and the publisher receive the message.

(2) persistent subscription

After the subscription relationship is established, the message will not disappear, regardless of whether the subscribers are online or not

(3) non-persistent subscription

Subscribers must be online all the time in order to receive messages.

When there is only one subscriber, it is about equal to peer-to-peer mode

5 message middleware application scenario 5.1 user registration asynchronous processing

Users of the website register, and will send email confirmation or short message after successful registration.

5.2 Log analysis use

Collect logs centrally for PV calculation and user behavior analysis

5.3 data replication

(1) copy data from the source to multiple destinations, usually requiring sequence or ensuring causal sequence

(2) it is used for data transmission across computer rooms, search, offline data calculation, etc.

5.4 delayed message delivery and temporary storage

(1) use message middleware as a reliable temporary storage place for messages.

(2) regular message delivery, such as simulating user second-kill access, and stress testing of system performance

5.5 message broadcast

(1) synchronous update of cache data

(2) push data to the application

For example, update the local cache:

6 message middleware message model classification 6.1 push push message model

The message producer sends the message to the messaging service, which in turn pushes the message to the message consumer.

6.2 pull pull message Model

The consumer requests the message service to accept the message, and the message producer pulls the message from the message middleware.

6.3 the difference between the two types

The difference between push push message and pull pull message

The following is my official account QR code picture, welcome to follow. If the article is reproduced, please indicate the source www.leexide.com.

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

Internet Technology

Wechat

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

12
Report