Updated on 2022-09-05 GMT+08:00

Retrieving Messages

Scenario

Messages can be retrieved from a queue.

Prerequisites

A queue has been created. The queue has at least one consumer group and at least one message.

Messages are retained in a queue for at least 72 hours and are deleted after expiry. You can specify the retention period of messages in advanced queues. The value range is 1 to 72 hours.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner of the management console and select a region.

    Select the same region as your application service.

  3. Click Service List, and choose Application > Distributed Message Service to open the DMS console.
  4. In the navigation pane, choose Queue Manager.
  5. Open the Retrieve Message dialog box using either of the methods:

    • Method 1

      In the queue list, choose More > Retrieve Message in the same row as the queue from which messages will be retrieved.

    • Method 2
      1. Click the name of the queue from which messages will be retrieved.
      2. Click the Consumer Groups tab.
      3. In the consumer group list, click Retrieve Message in the same row as the consumer group who will retrieve messages from the chosen queue.

  6. Specify parameters as shown in Table 1.

    Table 1 Parameter description

    Parameter

    Description

    Consumer Group Name

    Name of a consumer group.

    If you open the Retrieve Message dialog box by choosing More > Retrieve Message in the queue list, the Consumer Group Name parameter is by default set to the name of the first consumer group in the chosen queue.

    If you open the Retrieve Message dialog box by clicking Retrieve Message in the consumer group list, the Consumer Group Name parameter is by default set to the name of the chosen consumer group.

    Queue Polling Interval

    Interval at which DMS polls the queue for messages.

    The value can be: 3s, 5s, 10s, or 30s.

    Default value: 3s

    Message Type

    Type of messages to be retrieved.

    Options:

    • Normal

      Only normal messages are retrieved from the chosen queue.

    • Dead letter

      Only dead letter messages generated for the chosen consumer group are retrieved from the chosen queue.

    Default value: Normal

    NOTE:

    If the dead letter queue function is disabled in Creating a Queue, only normal messages are retrieved.

    Max. Message Count

    Maximum number of messages to be retrieved in a single polling cycle.

    The value can be 5 or 10.

    Default value: 5

    Message Labels

    Messages can be filtered by labels. Only messages with the chosen labels are retrieved from the chosen queue.

    1. If this parameter is not set, the filtering is not performed by default.
    2. When "Only retrieve messages containing all entered labels." is selected, only messages that match all labels are retrieved.
    3. If it is not selected, messages that match any one label are retrieved.

    This feature is supported only by standard queues and not by advanced queues.

    After you click the Start button, the console polls the queue at regular intervals for 5 minutes, even if there are messages in the queue. After 5 minutes, the polling stops automatically. To stop polling before then, click Stop and the polling will stop after the current cycle of polling completes.

    If you close the Retrieve Message dialog box or change the Consumer Group Name, Max. Message Count, or Queue Polling Interval while messages are being retrieved, the message retrieval will stop after the current cycle of polling completes.

    Retrieved messages are displayed in the list. To view details such as the message body, message size, ID, attribute count, and attributes, click More Details in the same row as the chosen message. Message retrieval will not be interrupted when you are viewing details.

    • Messages can be retrieved only once by each consumer group. Data about messages retrieved by the current consumer group is lost after the Retrieve Message dialog box is closed or another consumer group is selected to retrieve messages. However, the messages can still be retrieved by other consumer groups.
    • Messages from one queue are stored in different partitions to enable simultaneous retrieval of multiple messages by one consumer group. Each retrieval request can target messages in only one partition, preventing cross-partition management and access from adversely impacting performance. If the message queue contains only a few messages and messages are distributed over partitions, the number of messages in a single partition may be less than the number of messages you specified to be retrieved in a single polling cycle. This means that each polling cycle will return fewer messages than expected. However, all messages in the queue will be retrieved after multiple cycles.
    • Once a consumer group specifies a message label, the consumer group must use the label for all subsequent retrievals. If a consumer group changes a label during the next retrieval, the next retrieval will fail and the messages that fail to be retrieved cannot be retrieved again unless the consumer group resets the retrieval start position.
    Table 2 Parameters in the Messages Retrieved list

    Parameter

    Description

    Message Body (Condensed)

    Content of the message body.

    Content of messages in advanced queues is encoded with Base64.

    ID

    Handler of the message.

    Body Size

    Size of the message body.

    Operation

    Clicking More Details in the Operation column displays the complete message body, complete message ID, and complete message attributes of the message retrieved.

    The Operation column is not displayed if the message is retrieved from an advanced queue.