Delayed Publish
Delayed Publish
Delayed publish is an extended MQTT feature supported by EMQX. When a client publishes a message to EMQX with the topic prefix $delayed/{DelayInteval}, it triggers the delayed publish feature. The messages will be published after a period of time predefined by the user.
The specific format of the delay-publish topic is as below:
$delayed/{DelayInterval}/{TopicName}
$delayed: Messages prefixed with$delaywill be treated as messages that need to be delayed. The delay interval is determined by the content of the next topic level.{DelayInterval}: Specify the time interval for delaying the publishing of this MQTT message with the unit of second. The maximum allowed interval is 4294967 seconds. If{DelayInterval}cannot be parsed as an integer number, EMQX will discard the message and the client will not receive any information.{TopicName}: The topic name of the MQTT message.
Example:
$delayed/15/x/y: Publish MQTT message to the topicx/yafter 15 seconds$delayed/60/a/b: Publish MQTT message to the topica/bafter 1 minute$delayed/3600/$SYS/topic: Publish MQTT message to the topic$SYS/topicafter 1 hour
Configure Delayed Publish via Dashboard
-
Open EMQX Dashboard. In the left navigation menu, click Management -> Delayed Publish.
-
On the Delayed Publish page, you can configure as follows:
- Enable : Enable or disable delayed publish. By default, it is enabled.
- Max Delayed Messages : The max number of delayed messages.
- If you select Unlimited from the drop-down list, you cannot specify the number.
- If you select Custom from the drop-down list, you can specify the number.

Try Delayed Publish with MQTTX Client
Prerequisite
-
Basic publishing and subscribing operations using MQTTX Client
-
Start the MQTTX Client. Click the New Connection to create an MQTT connection named
Demo.- The localhost
127.0.0.1is used as an example in this demonstration.
- The localhost
TIP
For detailed instructions on creating an MQTT connection, see MQTTX Client.
-
Create another MQTT connection. Configure it as a subscriber.
-
Select the connection named
Demoin the Connections pane. Type the topic name$delayed/10/x/yin the topic text box and type the message asDelayed Message.$delayed: Indicates it is a delay message.10: Indicates the delayed interval is 10 seconds.x/y: Indicates the topic name of the message.- Select the connection named
Subscriber. Click the New Subscription button to create a subscription. Typex/yin the Topic textbox to subscribe to this topic.
-
Select the connection named
Demoin the Connections pane. Click the send button to send theDelayed Messagewith topic$delayed/10/x/y. -
Wait for 10 seconds. You will see the connection named
Subscriberreceive the delayed message after 10 seconds.

Try Delayed Publish with MQTTX CLI
Prerequisite
-
Basic publishing and subscribing operations using MQTTX CLI
-
Create a new connection as a subscriber and subscribe to the topic
t/1.
mqttx sub -t t/1 -v
- Open a new window in the terminal for the client as publisher. Use the following command to send a delayed message. The subscriber will receive the message after 5 seconds.
mqttx pub -t "\$delayed/5/t/1" -m "Hello Delayed msg"
