Introduction to the principle of message middleware

In the past few years, my colleagues around me have always concentrated on the research of message middleware. I don't know why, but this is inexplicably hot. In real work, I think 90% of systems don't need message middleware. Only those distributed systems with huge amount of information and high real-time customer experience will be used.

Not much nonsense, after all, it is also a skill, let's briefly introduce it.

1. First, we must understand what message middleware is:

Message Oriented Middleware (MOM) is an intermediary that provides message communication between two or more independently operating systems in a distributed environment.

2. The role of message middleware:

The role of message middleware: to interact with the invocation of services between various systems in the form of message communication

3. Features of message middleware:

A. Messages are received asynchronously, and the message sender does not need to wait for the response of the message received, which improves the performance of the entire application.
b. Reliable message reception: the message is sent out and stored in an intermediate container, and only after the message receiver receives the message Delete message

4. Application scenarios of message middleware

When communicating between multiple systems, it usually requires:
(1) Reliable transmission, data cannot be lost, sometimes, it is also required not to repeat transmission
(2) Asynchronous transmission, otherwise each system sends and receives data synchronously, and waits for each other , Resulting in poor system performance

5. More popular messaging middleware:

Fees: IBM MQSeries, BEA WebLogic JMS Server, Oracle AQ
open source: ActiveMQ, RocketMQ, Kafka

The above are some common sense questions of message middleware:

So when it comes to message middleware, I have to mention JMS

JMS is the Java Message Service (Java Message Service) application program interface. It is an API for message-oriented middleware (MOM) in the JavaEE platform. It is used to send messages between two applications or in a distributed system for asynchronous communication. .

The JMS specification
JMS defines the interface for accessing message middleware in Java, but does not implement it. The message middleware that implements the JSM interface is called JMS Provider, such as ActiveMQ

Therefore, our commonly used message middleware such as RocketMQ is the JMS Provider that implements the JSM interface

As follows, explain several concepts commonly used in JMS:

1. JMS Provider: Message middleware that implements JMS interfaces and specifications
2. JMS Message: JMS message, divided into 3 parts:
(1) Message header: Each message header field has corresponding getter and setter methods
(2) Message Attributes: If you need values ​​other than the message header fields, you can use message attributes
(3) Message body: encapsulate specific message data
3. JMS Producer: Message producer, client application that creates and sends JMS messages
4. JMS Consumer : Message consumers, client applications that receive and process JMS messages
5. JMS Domain: Message delivery domain, two message delivery domains are defined in the JMS specification:
(1) Point-to-point (point-to-point, abbreviated PTP or P2P) Message delivery domain. The message destination sent by the message delivery domain is called queue.
        Features:
        a. Each message can only have one consumer.
        b. There is no time correlation between the producer and the consumer of the message. Regardless of whether the message producer is running when the message consumer is extracting the message, the message consumer can still extract the message
        
(2) Publish/subscribe (publish/subscribe, abbreviated pub/sub) message delivery domain, which sends the message delivery domain The destination of the message is called topic.
        Features:
        a. Each message can have multiple consumers.
        b. There is time correlation between the producer and the consumer. Consumers who subscribe to a topic can only consume from it. Messages published after subscription.
             

In this mode of JMS, we can make analogy, analogy to JDBC link database driver.

The meaning of JDBC: It is a specification, the main purpose of design is to allow various database developers to provide Java programmers with standard data access classes and interfaces, making it possible to develop Java applications independent of DBMS (database changes , The driver changes, but the application remains unchanged) Java design specification interface, major database manufacturers comply with the specification implementation, Java programmers do not need to consider the implementation details, only need to call the API.

JDBC API (Unified Application Interface) JDBC Driver Manager (Driver Manager) JDBC database driver driver is essentially a Java class, this class implements the interface defined by JavaAPI. Generally, in the application, the database is connected and JDBC is called. For the interface, first, the implementation of the JDBC driver of a specific manufacturer must be loaded into the system memory and then used by the system. The so-called driver here is actually a class that implements the java.sql.Driver interface

By analogy, JMS is also only one specification. Middleware that implements this specification, such as ActiveMQ, RocketMQ, Kafka, etc., can be used directly.

In addition, the problem of the above picture: RocketMQ does not implement the JMS protocol, but implements a similar protocol. The picture has errors.

Guess you like

Origin blog.csdn.net/LB_Captain/article/details/108431945