All Products
Search
Document Center

Simple Message Queue (formerly MNS):Get started with topic-based messaging

Last Updated:Sep 02, 2024

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

  1. Log on to the SMQ console.

  2. In the left-side navigation pane, click Queues.

  3. In the top navigation bar, select a region.

  4. On the Queues page, click Create Queue.

  5. 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

  1. Log on to the SMQ console.

  2. In the left-side navigation pane, click Topics.

  3. In the top navigation bar, select a region.

  4. On the Topics page, click Create Topic.

  5. 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.

  1. On the Topics page, find the topic that you want to view and click View Subscriptions in the Actions column.

  2. In the View Subscriptions to Topic panel, click Subscriptions.

  3. On the Subscriptions page, click Create Subscription.

  4. 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.

  1. On the Topics page, find the topic and click Publish Message in the Actions column.

  2. 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.

  1. On the Queues page, find the queue and choose More > Send Messages in the Action column.

  2. 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.

  3. In the Receive Message section of the Quick Experience page, click Receive Message.

    A list of messages appears in the Receive Message section.

  4. 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

  1. On the Queues page, find the queue that you want to delete and choose More > Delete in the Actions column.

  2. In the Note message, read the note and click OK.

    The queue is deleted from the Queues page.

Delete a topic

  1. On the Topics page, find the topic that you want to delete and choose More > Delete in the Actions column.

  2. In the Note message, read the note and click OK.

    The topic is deleted from the Topics page.

    Warning

    After a topic is deleted, you cannot restore the data of the topic.