First, why should the use of message queues
1. decoupled and asynchronous
Using message queues may become asynchronous call synchronous calls, while reducing the degree of coupling between system modules
2. Clipping
Object when the system pressure is too large, the operation of the cache in the message queue, the message is read back continuously operated, achieve peak clipping
3. Multiplexing (scalability)
If you want to send a message to the system A plurality of systems, each additional subsystem case, the code would need to modify the system A, then using message queues, system A sends a message to the message queue, the other system can read the message. Just to the message queue and when the new system were to read the message
Second, the need for precautions
1. Note that improve usability
MQ when the server goes down, the backup program.
2. The complexity of the system to improve
- Message repeated consumption problem
- Message loss problem
- Message delivery order issue
3. Consistency
When the multi-processing system with a message, a synchronous call returns a failure can be directly, using an asynchronous call how the message queue processing
Third, the common messaging middleware comparison
ActiveMQ | RabbitMQ | RocketMQ | Kafka | |
---|---|---|---|---|
Implementation language | java | erlang | java | scala |
Throughput | Ten thousand | Ten thousand | One hundred thousand | One hundred thousand |
aging | ms | Microsecond | ms | ms |
Availability | High (master-slave) | High (master-slave) | Very high (distributed) | Very high (distributed) |