Before messages are processed, DMS allows them to be stored in queues. Users do not need to worry about message storage or management. All they need to do is to focus on developing applications.
Usage Mode Suggestions
Users can use DMS in their applications through the following methods:
- Integrating DMS into the web services of other enterprise cloud infrastructures, making applications more reliable, flexible, and scalable.
- Using DMS to create a queue. In this queue, every message is regarded as a task and a process is required to complete such tasks. One or more processes can read and execute tasks in the queue.
- Connecting message queues to micro services to build the micro service architecture.
- Storing notifications of important events of services in DMS message queues. Each event has a matching message in the queue, and applications that need to know the event information can read and process the message.
When using DMS, users can take some optimization measures to improve the API call efficiency, as well as message sending and consumption efficiency.
To improve the message sending and consumption efficiency, users are advised to use the batch message sending and consumption mode, which can effectively lower the number of API calls and minimize service fees.
During message sending and consumption, DMS, producers, and consumers collaborate to ensure service reliability. Best practice for producers and consumers of DMS include the following:
- After messages are sent, the producer checks for message sent confirmation returned from DMS. If message sending failed, the producer re-sends the messages.
After messages are produced, the producer waits for the message sending API to send an acknowledgement (ACK) to determine whether messages were sent successfully. If any abnormality occurs during message sending, the producer does not receive an ACK. In this case, the producer determines whether to re-send messages. If the producer receives a successful ACK, the messages have been reliably stored by DMS.
- During message consumption, the consumer consumes messages and then confirms whether messages have been consumed successfully.
Produced messages are stored in the DMS service storage medium. During message consumption, the consumer obtains messages stored in the DMS service. Next, the consumer consumes the messages, records message consumption status as successful or failed. The consumer then submits the consumption status to the DMS service. Based on the consumption status, the DMS service determines whether to consume the next batch of messages or re-consume the unsuccessfully consumed messages.
During the message consumption process, the message consumption status may not be successfully submitted due to some abnormalities. In this case, the corresponding batch of messages will be re-obtained by the consumer in the next message consumption request.
Based on the preceding mechanism, messages may be sent or consumed repeatedly