This topic describes how to get started with topic-based messaging in the Simple Message Queue (formerly MNS) console.
Prerequisites
SMQ is activated, and a RAM user is authorized to access SMQ. For more information, see Activate SMQ and authorize RAM users to access SMQ.
Create an SMQ queue
Log on to the SMQ console.
In the left-side navigation pane, click Queues.
In the top navigation bar, select a region.
On the Queues page, click Create Queue.
In the Create Queue panel, set the following parameters and click OK.
Name: the name of the queue.
Maximum Message Length: the maximum body 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.
Visibility Timeout Period: the duration for which a message stays in the Inactive state after the message is received from the queue.
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.
Scheduled Period: the period after which all messages sent to the queue are consumed.
Enable Logging Feature: specifies whether to enable the logging feature.
The queue is displayed on the Queues page.
Create a topic
Log on to the SMQ console.
In the left-side navigation pane, click Topics.
In the top navigation bar, select a region.
On the Topics page, click Create Topic.
In the Create Topic panel, set the following parameters and click OK.
Name: the name of the topic.
Maximum Message Length: the maximum body length of the message that is sent to the topic.
Enable Logging Feature: specifies whether to enable the logging feature.
After you create the topic, the Topic Details page appears.
Create a subscription
You can create a subscription for a topic. This way, the messages that are sent to the topic are pushed to the queue that subscribes to the topic.
On the Topics page, find the topic that you want to view and click View Subscriptions in the Actions column.
In the View Subscriptions to Topic panel, click Subscriptions.
On the Subscriptions page, click Create Subscription.
In the Create Subscription panel, set the following parameters and click OK.
Name: the name of the subscription.
Subscription: the type of the subscription. The default value is HTTP.
Receiver Endpoint: the endpoint of the receiver.
(Optional) Message Filtering Tag: the tag that is used to filter messages.
Retry Policy: the retry policy that is applied if an error occurs during message delivery from an SMQ topic to the receiver.
Valid values:
Backoff Retry
Exponential Decay Retry
Message Format: the format of the message that is pushed to the receiver.
Valid values:
SIMPLIFIED
JSON
XML
The subscription appears on the Subscriptions page.
Publish a message
You can publish a message to a topic, and then push the message to the queue that subscribes to the topic.
On the Topics page, find the topic and click Publish Message in the Actions column.
On the Try Publishing Message to Topic page, set the following parameters and click Publish Message.
Message Content: the body of the message.
(Optional) Message Tag: the tag that is used to filter messages.
Subscription Type: the subscription type of the message. In this example, messages are pushed to a queue.
"The message is sent" appears on the page.
Receive a message
After a message is published to a queue, you can receive it from the queue. Then, you can check the message content to ensure that the published message is the same as the received message. This topic describes how to receive a message pushed to a specified queue of a topic in the SMQ console.
On the Queues page, find the queue and choose in the Action column.
Optional. In the Receive Message section of the Quick Experience page, click Edit Parameters of Receiving Messages. In the Edit Parameters of Receiving Messages panel, set the Receive Times and Polling Period parameters, and then click OK.
In the Receive Message section of the Quick Experience page, click Receive Message.
A list of messages appears in the Receive Message section.
Optional. Find a message in the message list and click Details in the Actions column. In the Message Details dialog box, view the message content and other information.
Delete a queue
On the Queues page, find the queue that you want to delete and choose in the Actions column.
In the Note message, read the note and click OK.
The queue is deleted from the Queues page.
Delete a topic
On the Topics page, find the topic that you want to delete and choose in the Actions column.
In the Note message, read the note and click OK.
The topic is deleted from the Topics page.
WarningAfter a topic is deleted, you cannot restore the data of the topic.