Simple Message Queue (formerly MNS) lets you push messages published to a topic to a queue. This topic describes how to perform this task.
Step 1: 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 created queue appears on the Queues page.
Step 2: Create a topic
In the navigation pane on the left, choose .
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.
You are redirected to the Topic Details page of the topic.
Step 3: Create a subscription
Current account
In the navigation pane on the left, choose .
On the Subscriptions page, click Create Subscription.
In the Create Subscription panel, configure the following settings and click OK.
Topic Name: The name of the topic to which the subscription belongs.
Subscription Name: Enter a name for the subscription.
Subscription: Select Queue.
Cross-Account: Select Inter-account.
Receiver Endpoint: Select the queue that you created in Step 1.
(Optional) Message Filtering Tag: Enter a tag to filter messages.
Retry Policy: Select a retry policy.
BACKOFF_RETRY: Retries are attempted three times. The interval between retries is a random value between 10 and 20 seconds.
DECAY_RETRY: Retries 176 times over a total period of one day. The interval is measured in seconds and increases as follows: 2^0, 2^1, ..., 512, 512, ..., 512.
Message Format: Select a message push format.
Cross-account
In the navigation pane on the left, choose .
On the Subscriptions page, click Create Subscription.
In the Create Subscription panel, configure the following settings and click OK.
Topic Name: The name of the topic to which the subscription belongs.
Subscription Name: Enter a name for the subscription.
Subscription: Select Queue.
Cross-Account: Select Cross-Account.
Receiver Endpoint: Enter the Alibaba Cloud Resource Name (ARN) of the destination queue. You can find the ARN of the queue in the Basic Information section of the Queue Details page. The format is
acs:mns:cn-hangzhou:${accountId}:/queues/${queueName}.Service-linked Role: Enter the ARN of the RAM role for cross-account authorization. For information about how to grant permissions to a RAM role and obtain its ARN, see Cross-account push authorization.
(Optional) Message Filtering Tag: Enter a tag to filter messages.
Retry Policy: Select a retry policy.
BACKOFF_RETRY: Retries are attempted three times. The interval between retries is a random value between 10 and 20 seconds.
DECAY_RETRY: Retries 176 times over a total period of one day. The interval is measured in seconds and increases as follows: 2^0, 2^1, ..., 512, 512, ..., 512.
Message Format: Select a message push format.
Step 4: Publish a message
On the Topics page, find the topic and click Publish Message in the Actions column.
On the Publish Message To Topic - Quick Start page, configure the following settings and click Publish Message.
Message Content: Enter the message content.
(Optional) Message Tag: Enter a tag to filter messages.
Subscription Type: Select Queue.
Step 5: Receive a message
On the Queues page, find the queue, and in the Action column, choose .
Optional: On the Send And Receive Messages In Queue - Quick Start 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 And Receive Messages In Queue - Quick Start page, in the Receive Message section, click Receive Message.
The list of messages in the queue is displayed in the Receive Message section.
Optional: In the message list, find the message, and click Details in the Actions column. In the Message Details dialog box, view information such as the message content.