What is the MQ?
MQ called the Message Queue, i.e. the message queue message oriented middleware. Producer to write the message in the message queue, the queue of messages consumption can be read.
It refers to the use of data exchange mechanisms for efficient and reliable messaging platform-independent and based on the data communication in distributed systems integration. Transfer and message queuing model is provided by providing a message in a distributed application environment decoupling, elastically stretchable, redundant storage, flow clipping, asynchronous communication, data synchronization.
Such a process is generally: a sender sends a message to the message server, the message stored in the message server several queue / topic in the topic, when appropriate, back to the message server forwards the message to the recipient. In this process, sending and receiving is asynchronous, that is, send no waiting, and the sender and receiver of the life cycle is not necessarily related; in particular, publish pub / subscribe under sub mode, you can also complete many of communication, that allows a message has multiple recipients.
MQ major role
- Asynchronous: the caller without waiting for asynchronous processing;
- Decoupling: solve the problem of calls between the coupling systems;
- Consumers peak: to withstand peak flow, protecting the main business;
MQ advantages and disadvantages
advantage:
-
Asynchronous processing mode: a message sender can send a message without waiting for the response. Message sender to send a message to a virtual channel (topic or queue) on; the message recipient or subscribe to love listening to the channel. A message may eventually forwarded to one or more of the message recipient, the recipient of these messages are synchronized without having to make a response to the message sender. The entire process is asynchronous;
-
Decoupling between the application sender and receiver do not have to understand each other, only an acknowledgment message. The sender and receiver need not be online at the same time.
-
Available for clipping on high-traffic, to ensure the smooth operation of the system.
Disadvantages:
- Reduce system availability, in general, the more external dependencies introduced, the more vulnerable the system, each dependency problem will cause the entire link business problems;
- Increase the complexity of the system, to consider the various situations, for example, loss idempotency message, message, and other consumer sequence;
- Distributed things, data consistency problems;
Comparison of various types of MQ
MQ is just a concept, the idea of flying in the sky, there must be ground to achieve. Whether Which messaging middleware, has the following technical dimensions:
Technical Dimensions | ActiveMQ | RocketMQ | RabbitMQ | Kafka |
---|---|---|---|---|
PRODUCER-CUMSUMER | stand by | stand by | stand by | stand by |
PUBLISH-SUBSCRIBE | stand by | stand by | stand by | stand by |
REQUEST-REPLY | stand by | stand by | stand by | * |
API integrity | high | (Static configuration) | high | high |
Document Integrity | high | in | high | high |
Multi-language support | Support, Java priority | stand by | Language-independent | Support, Java priority |
Stand-alone Throughput | Ten thousand | Ten thousand | Ten thousand | One hundred thousand |
Message delay | * | * | Microsecond | Millisecond |
Availability | High (master-slave) | high | High (master-slave) | Very high (Distributed |
Message loss | * | * | low | In theory, will not be lost |
Repeat message | * | * | Controllable | In theory there will be repeated |
Getting Started | Have | no | Have | Have |
First deployment difficulty | * | high | low | in |
Programming language | Java | Java | erlang | scala |
Applications | Small and medium sized projects | Large-scale projects, clusters | In large-scale projects | Big Data |