RabbitMQ is a distributed message middleware developed in the Erlang language and open-sourced. It supports the Advanced Message Queuing Protocol (AMQP) and client libraries in various programming languages such as Java, Golang, PHP, and Python.

Features

  • Reliability: Ensures reliability through message persistence, transaction support, consumer and transmission acknowledgment, etc.
  • Routing Mechanism: Supports mainstream subscription and consumption models such as broadcast, subscription, header matching, etc.
  • Scalability: Multiple RabbitMQ nodes can form a cluster and can dynamically expand the cluster according to actual business needs.
  • High Availability: Queues can be set as mirrors on machines in the cluster, making queues still available in case of problems with some nodes.
  • Multiple Protocols: In addition to native AMQP support, RabbitMQ also supports multiple messaging middleware protocols such as STOMP, MQTT, etc.
  • Multi-language Clients: RabbitMQ supports almost all commonly used languages, such as Java, Python, Ruby, PHP, C#, JavaScript, etc.
  • Management Interface: RabbitMQ provides a user-friendly interface for monitoring and managing messages and cluster nodes.
  • Plugin Mechanism: RabbitMQ provides many plugins for extensive extensions, and users can also write their own plugins.

Main Use Cases

Asynchronous Processing

Non-core or less important parts of the business process can be asynchronously notified to the target system using message notification, allowing the main business process to promptly respond without synchronously waiting for the processing results from other systems.

Application Decoupling

Business expansion can be achieved based on message subscription mechanisms. For example, in an e-commerce ordering scenario, when a user places an order, an order message is generated. The warehouse module can subscribe to the order message for shipping, the points module can subscribe to the order message for adding points, and the SMS module can subscribe to the order message for sending text messages, and so on.

Peak Shaving

As there may be differences in the processing capabilities of upstream and downstream systems, message queues can act as a regulator to allow downstream systems to handle traffic at a steady pace.

For example, in the case of successfully paying for an order and notifying the warehouse to ship, if the current order module supports a high concurrency of 1000 and the warehouse shipping supports only 100, introducing a message queue can allow the warehouse module to subscribe to the order message and handle shipping slowly in a queue.

ps: It's like queuing for the subway.