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

Creating a Message

Scenario

Messages can be sent to a chosen queue.

The size of each message, including the message body and attributes, cannot exceed 512 KB. The body includes the message content and a few bytes of additional JSON information.

If the Kafka SDK is used to create messages, the maximum size of a single message is 10 MB. If the DMS console is used to create messages, the maximum size of a single message is 512 KB.

Prerequisites

A queue has been created.

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 Create Message dialog box using either of the methods:

    • Method 1

      In the queue list, click Create Message in the same row as the queue to which messages will be sent.

    • Method 2
      1. Click the name of the queue to which messages will be sent.
      2. Click Create Message in the upper right corner of the queue details page.

  6. Specify parameters as shown in Table 1.

    If you want to add message labels, specify Message Labels.

    If you want to add attributes, specify Name and Value, and then click Add.
    Table 1 Parameter description

    Parameter

    Description

    Message Body

    Body of the message to be sent.

    When using the DMS console to send messages, characters that are reserved in the JSON format will be escaped in the message body content. For example, "it's not you, it's me" would be escaped to \"it's not you, it's me\".

    Delay Message Delivery

    An indicator of whether message delivery delay is enabled.

    Delivery of messages added to this queue in DMS will be delayed for the chosen amount of time.

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

    Delivery Delay

    Amount of time to delay delivery of all messages added to this queue.

    Options: 1 minute, 5 minutes, 30 minutes, 1 hour, and 1 day

    Default value: 5 minutes

    Message Labels (optional)

    When using DMS, you can use labels to filter the messages you want to retrieve from the chosen queue.

    A message label is 1 to 64 characters long. Only letters, digits, hyphens (-), and underscores (_) are allowed.

    Each message has a maximum of three labels.

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

    Message Attributes

    Attribute of a message, which is composed of the name and value in the key-value format. Attributes are not part of the message body but are sent and retrieved along with it.

    Attribute names are mandatory and must be unique in the same message.

    If you enter attribute names or values on the DMS console, spaces are allowed in attribute names and values, but not before and after them. For example, in DMS, " ab c " is converted to "ab c".

    NOTE:

    If you use APIs to access DMS, spaces are allowed in, before, and after attribute names and values.

    Message attributes are supplementary to the message body and can be sent and retrieved along with it. You can specify multiple message attributes, as long as the size of the message remains within 512 KB.

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

    Successfully added attributes will be displayed in the list. To delete an attribute, click Delete in the same row as the attribute.

  7. Click OK.

    In the queue list, the value of Messages for the chosen queue will increment by one.

    In the consumer group list of the chosen queue, the value of Messages Available for those consumer groups will also increment by one if consumer groups exist for the queue.