Scenarios
This document uses the Spring Boot Starter SDK as an example to introduce the operation process of sending and receiving messages through an open-source software development kit (SDK), helping you better understand the whole process of sending and receiving delayed messages.
Prerequisites
You have obtained the client connection parameters as instructed in SDK Overview. Operation Steps
Sending Messages
Like sending normal messages, you just need to pass the delay level when calling a sending method.
SendResult sendResult = rocketMQTemplate.syncSend(
destination,
MessageBuilder.withPayload(message).build(),
5000,
delayLevel);
The following table describes the mapping between delay levels and specific delay times.
|
1 | 1s |
2 | 5s |
3 | 10s |
4 | 30s |
5 | 1m |
6 | 2m |
7 | 3m |
8 | 4m |
9 | 5m |
10 | 6m |
11 | 7m |
12 | 8m |
13 | 9m |
14 | 10m |
15 | 20m |
16 | 30m |
17 | 1h |
18 | 2h |
Consuming Messages
It is the same as normal messages and requires no special processing.