Message queue protocol

Message queue protocol

1. What is an agreement

Insert picture description here
We know that message middleware is responsible for the three parts of data transmission, storage, and distribution. The process of data storage and distribution must follow certain conventions and conventions. Do you use the underlying TCP/IP, UDP protocol or Others take their own constructions, etc., and these conventions are called agreements.

The so-called protocol refers to:
1: A set of conventions that the computer's underlying operating system and application programs abide by when communicating. Only by following the common conventions and specifications can the system and the underlying operating system communicate with each other.
2: Different from general network applications, it is mainly responsible for data reception and transmission, so the performance is relatively high.
3: The protocol must strictly abide by the specifications for the data format and the exchange of data between computers.

Two, the three elements of the network protocol

1. Grammar. Syntax is the structure and format of user data and control information, as well as the order in which data appears.
2. Semantics. Semantics is to explain the meaning of each part of the control information. It specifies what kind of control information needs to be sent, as well as what actions to complete and what kind of responses to make.
3. Timing. Timing is a detailed description of the sequence of events.

For example, when I send a message to MQ, in what data format is sent to the queue, what is the meaning of each part, the actions executed after sending, and the actions of consumers to consume the message, the response result and feedback after the consumption is What, and then proceed in accordance with the corresponding execution order. If you still don’t understand: http request protocol that everyone is in touch with every day:

1: Syntax: http specifies the format of request messages and response messages.
2: Semantics: The request initiated by the client is called a request. (This is a definition, and what you initiate is a post/get request)
3: Timing: A request corresponds to a response. (There must be a response to the request first, this is the timing)

The message middleware does not use the http protocol, but common message middleware protocols are: OpenWire, AMQP, MQTT, Kafka, and OpenMessage protocols.

Interview question: Why doesn't the message middleware directly use the http protocol?

1: Because the HTTP request header and response header are more complicated, including additional functions such as cookie, data encryption and decryption, status code, response code, etc., but for a message, we don’t need to be so complicated. , There is no such necessity. It is actually responsible for data transmission, storage, and distribution. High performance must be pursued. Try to be concise and fast.
2: In most cases, http is mostly short links. In the actual interaction process, a request to response is likely to be interrupted. After the interruption, it will not be persisted, which will cause the loss of the request. This is not conducive to the business scenario of message middleware, because message middleware may be a long-term process of obtaining messages. If problems and failures occur, data or messages must be persisted. The purpose is to ensure the high reliability and reliability of messages and data. Robust operation.

Three, AMQP protocol

AMQP: (full name: Advanced Message Queuing Protocol) is an advanced message queuing protocol. Jointly designed by JPMorgan Chase Group and other companies. It is an application layer standard advanced message queuing protocol that provides unified messaging services. It is an open standard for application layer protocols and is designed for message-oriented middleware. Clients and message middleware based on this protocol can transmit messages, and are not restricted by different client/middleware products, different development languages ​​and other conditions. Implementations in Erlang include RabbitMQ and so on.
1: Distributed transaction support.
2: Persistence support for messages.
3: High performance and high reliability message processing advantages.

Supporters of the AMQP protocol:
Insert picture description here

Four, MQTT protocol

MQTT protocol: (Message Queueing Telemetry Transport) message queue is an instant messaging protocol opened by IBM and an important part of the IoT system architecture.
1: Lightweight
2: Simple structure
3: Fast transmission, no transaction support
4: No persistence design.
Application scenarios:
1: Suitable for limited computing power
2: Low bandwidth
3: Unstable network scenarios.
Insert picture description here

Five, OpenMessage protocol

Insert picture description here
It is an application development standard for distributed messaging middleware, stream processing and other fields jointly created by companies such as Ali, Yahoo, Didi Chuxing, and Stremalio in recent years.
1: Simple structure
2: Fast analysis speed
3: Support transaction and persistence design.

Six, Kafka agreement

Insert picture description here
The Kafka protocol is a binary protocol based on TCP/IP. The message is divided by length and consists of some basic data types.
Features are:
1: Simple structure
2: Fast analysis speed
3: No transaction support
4: Persistent design

Protocol: It is a convention and mechanism built on the basis of the tcp/ip protocol. Its main purpose is to transmit more information
Insert picture description here

Guess you like