Create a topic, subscribe a queue, publish a message, and verify delivery using the topic-based model in the Simple Message Queue (formerly MNS) console.
Prerequisites
Activate Simple Message Queue (formerly MNS) and grant permissions
Create a queue
Log on to the SMQ console.
In the left-side navigation pane, choose Queue Model > Queues.
In the top navigation bar, select a region.
On the Queues page, click Create Queue.
-
In the Create Queue panel, configure the following parameters and click OK.
Name: the name of the queue.
Maximum Message Length: the maximum length of the message that is sent to the queue.
Long Polling Period: the maximum duration for which long polling requests are held after the ReceiveMessage operation is called. The value 0 indicates that long polling is disabled.
Visibility Timeout Period: the duration for which a message stays in the Inactive state after the message is received from the queue. For more information, see Message visibility.
Message Retention Period: the maximum duration for which a message exists in the queue. After the specified retention period, the message is deleted regardless of whether the message is received.
Message Delay Period: the period after which all messages sent to the queue are consumed.
Enable Logging Feature: specifies whether to enable the logging feature. If this feature is enabled, SMQ automatically pushes the operation logs of this queue to the specified Logstore. You can then view the message trace, delay, and other information from the logs. For more information, see Log management.
The queue is created and appears on the Queues page.
Create a topic
Log on to the SMQ console.
In the left-side navigation pane, choose Topic Model > Topics.
In the top navigation bar, select a region.
-
On the Topics page, click Create Topic.
-
In the Create Topic panel, configure the following parameters and click OK.
Name: the name of the topic.
Maximum Message Length: the maximum length of the message that is sent to the topic.
Enable Logging Feature: specifies whether to enable the logging feature. If this feature is enabled, SMQ automatically pushes the operation logs of this topic to the specified Logstore. You can then view the message trace, delay, and other information from the logs. For more information, see Log management.
The Topic Details page of the topic appears.
Create a subscription
Create a subscription to push topic messages to a queue.
-
On the Topics page, find the topic, and in the Actions column, click View Subscriptions.
-
In the View Subscriptions For Topic panel, click the Subscriptions tab.
-
On the Subscriptions page, click Create Subscription.
-
In the Create Subscription panel, configure the following parameters and click OK.
-
Name: Subscription name.
-
Subscription: Push type. Default: HTTP.
-
Receiver Endpoint: Endpoint for message delivery.
-
Optional: Message Filtering Tag: Tag for filtering messages.
-
Retry Policy: Retry policy for failed message pushes.
Available retry policies:
-
Backoff retry
-
Exponential decay retry
-
-
Message Format: Format of messages pushed to the endpoint.
Available message formats:
-
SIMPLIFIED
-
JSON
-
XML
-
The subscription is created and appears on the Subscriptions page.
-
Publish a message
Publish a message to a topic. The message is pushed to the subscribed queue.
-
On the Topics page, find the topic, and in the Actions column, click Publish Message.
-
On the Publish Message To Topic page, configure the following parameters and click Publish Message.
-
Message Content: Body of the message to publish.
-
(Optional) Message Tag: Tag for message filtering.
-
Subscription Type: Target subscription type. This example uses a queue.
A "Message sent successfully" message appears.
-
Receive a message
Retrieve the published message from the queue to verify delivery.
-
On the Queues page, find the queue, and in the Action column, choose .
-
Optional: On the Send/Receive Messages For Queue page, in the Receive Message section, click Edit Parameters of Receiving Messages. In the Edit Parameters of Receiving Messages panel, configure Receive Times and Polling Period, and then click OK.
-
On the Send/Receive Messages For Queue page, in the Receive Message section, click Receive Message.
The queue messages appear in the Receive Message section.
-
Optional: In the message list, find the message, and in the Actions column, click Details. In the Message Details dialog box, view the message body and other information.
Delete the queue
-
On the Queues page, find the queue, and in the Actions column, choose .
-
In the Prompt dialog box, read the information and click OK.
The queue is deleted from the Queues page.
Delete the topic
-
On the Topics page, find the topic, and in the Actions column, choose .
-
In the Prompt dialog box, read the information and click OK.
The topic is deleted from the Topic List page.
WarningDeleting a topic permanently removes all its data.