Scenario of Flash Sales
Flash sales are a very common scenario in e-commerce systems, and there are many solutions available. Using TDMQ for RabbitMQ is considered one of the effective methods.
For complex inventory deduction scenarios (such as those involving product information or other systems), it is recommended to perform inventory deduction using the database. An asynchronous method can be used to handle high concurrency in inventory updates.
1. When a user places an order, the order is not generated immediately; instead, all orders are sequentially placed into a queue.
2. The order module obtains orders from the queue based on its own processing speed and performs the operation of "inventory deduction after orders are placed".
3. After the order is generated successfully, the user can proceed with payment.
This method is specifically designed for the scenario of flash sales, ensuring fairness based on the "first-come, first-served" principle. All users have the opportunity to place an order, and then wait for order processing and order generation (orders fail to be generated if the inventory is insufficient).
Priority Messages
When messages are consumed, if the importance of them varies, and higher-priority messages are desired to be consumed preferentially, the priority queue feature of TDMQ for RabbitMQ can be used in this case to ensure that messages with higher priority are consumed first.
See the following business scenario for reference:
For example, there is a scenario of an order payment reminder in the system. If customers place the order in the e-commerce system, the system will send it to the customer timely. If payment is not made within a specified time period, an SMS reminder will be sent to the customer. However, the processing method of the speed differentiates between major and minor customers. The payment reminders for major customers need to be processed with higher priority, while reminders for minor customers have lower priority.
The priority queue feature of TDMQ for RabbitMQ perfectly supports this scenario, preventing high-priority messages from being delayed. For example, orders from major customers are assigned a relatively higher priority to ensure timely processing, while others use the default priority.
Scenario of Delayed Messages
In the actual business system, there are requirements for sending delayed messages. If customers implement the delay logic themselves, ensuring reliability and delay accuracy can be challenging. Using a message middleware, such as TDMQ for RabbitMQ, can handle such requirements effectively. Scenarios for using delayed messages include:
In an order system, users have 30 minutes to complete payment after placing an order. If payment is not successful within this time range, the order will be processed as an exception. In this case, the delayed message capability of TDMQ for RabbitMQ can be used to handle these timed-out orders.
In an Internet of Things (IoT) system, users may want to remotely control smart devices to operate at a specified time using their mobile phones. In this case, the control instructions can be sent to the delay queue, which sends the control instructions to the smart devices at the specified time.
Message Broadcasting
Many business systems need to broadcast information to downstream systems. Using RPC to achieve this can create tight coupling and increase pressure on the upstream business systems. In this case, the fanout exchange of TDMQ for RabbitMQ can be used to handle these requirements. Applicable scenarios include:
In a massively multiplayer online game (MMO), it can be used for leaderboard updates or other global events.
In the sports news website, the fanout exchange can be used to distribute near-real-time score updates to the clients.
In a distributed system, it can be used to broadcast various status and configuration updates.
In a group chat, it can be used to distribute messages among participants.
Scenario of Flexible Routing
With the rise of microservice architectures, services are split more granularly, and service data is often sent as messages to different queues using carefully designed distribution policies. The flexible message routing capability of TDMQ for RabbitMQ can be fully used to distribute messages to target queues. Applicable scenarios include:
In a log processing scenario, logs are routed to different queues based on the type. For example, error logs are shipped to a separate processing queue with higher priority.
In an e-commerce logistics system, the shipment information is distributed to different consumers based on the region.
Complex routing scenarios.