All Products
Search
Document Center

Message Service:Push messages to a queue

Last Updated:Jun 24, 2024

Message Service (MNS) allows you to push the messages that are published to a topic to a queue. This topic describes how to push messages to a queue.

Step 1: Create a queue

  1. Log on to the MNS 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, configure the following parameters and click OK:

    • Name: the name of the queue.

    • Maximum Message Length: the maximum length of a 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 is retained in the queue. After the specified retention period ends, 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.

    After the queue is created, the queue is displayed on the Queues page.

Step 2: Create a topic

  1. Log on to the MNS 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, configure the following parameters and click OK:

    • Name: the name of the topic.

    • Maximum Message Length: the maximum length of a message that is sent to the topic.

    • Enable Logging Feature: specifies whether to enable the logging feature.

    After the topic is created, you are navigated to the Topic Details page of the topic.

Step 3: Create a subscription

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

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

  3. On the Manage Subscriptions page, click Create Subscription.

  4. In the Create Subscription panel, configure the following parameters and click OK:

    • Name: the name of the subscription.

    • Subscription: the type of the subscription. Select Queue.

    • Receiver Endpoint: the endpoint of the receiver. Select the queue that is created in Step 1.

    • Message Filtering Tag: optional. The tag that is used to filter messages.

    • Retry Policy: the retry policy.

    • Message Format: the format in which messages are pushed.

Step 4: Publish messages

  1. On the Topics page, find the topic that you want to manage and click Publish Message in the Actions column.

  2. On the Try Publishing Message to Topic page, configure the following parameters and click Publish Message:

    • Message Content: the content of the message.

    • Message Tag: optional. The tag that is used to filter messages.

    • Subscription Type: the type of the subscription. Select Queue.

Step 5: Receive messages

  1. On the Queues page, find the queue that you want to manage 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, configure 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.

    The received messages are displayed 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 information about the message, such as the message content.