After you purchase and deploy a Message Queue for Apache Kafka instance, you can send messages in the Message Queue for Apache Kafka console to check whether the broker is normal with efficiency.

Prerequisites

A Message Queue for Apache Kafka instance is purchased and deployed, and it is in the Running state.

Procedure

To perform a quick test on the Message Queue for Apache Kafka broker, perform the following steps:

  1. Create a topic
  2. Send a message
  3. View the partition status
  4. Query messages by offset

You can repeat Steps 2 to Step 4 multiple times. If all repeated steps are successful, the broker works as expected.

Note If the broker works as expected but messages cannot be sent, we recommend that you check the caller, such as the native client or an ecosystem component.

Create a topic

Create a topic for receiving messages.

  1. Log on to the Message Queue for Apache Kafka console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance resides.
  3. On the Instances page, click the name of the instance that you want to manage.
  4. In the left-side navigation pane, click Topics.
  5. On the Topics page, click Create Topic.
  6. In the Create Topic panel, set the properties of the topic and click OK.
    createtopic
    Parameter Description Example
    Name The name of the topic. demo
    Description The description of the topic. demo test
    Partitions The number of partitions in the topic. 12
    Storage Engine The storage engine of the topic.

    Message Queue for Apache Kafka supports the following storage engines. You can select a storage engine that meets your business requirements based on the information provided in the panel.

    • Cloud Storage
    • Local Storage
    Cloud Storage
    Message Type The message type of the topic.
    • If you set the Storage Engine parameter to Cloud Storage, this parameter is automatically set to Normal Message.
    • If you set the Storage Engine parameter to Local Storage, this parameter is automatically set to Partitionally Ordered Message.
    Normal Message
    Log Cleanup Policy The log cleanup policy for the topic.

    If you set the Storage Engine parameter to Local Storage, you must set the Log Cleanup Policy parameter.

    Message Queue for Apache Kafka supports the following log cleanup policies. You can select a log cleanup policy that meets your business requirements based on the information provided in the panel.

    • Delete
    • Compact
    Compact
    Tag The tags to be attached to the topic. demo

Send a message

Send a message to the topic that you created.

  1. On the Topics page, find the topic based on which you want to send and consume messages, and choose More > Quick Start in the Actions column.
  2. In the Start to Send and Consume Message panel, set the parameters or use the method as prompted to send a test message.
    • Set the Method of Sending parameter to Console.
      1. In the Message Key field, enter the key of the test message, such as demo.
      2. In the Message Content field, enter the content of the test message, such as {"key": "test"}.
      3. Set the Send to Specified Partition parameter to specify whether to send the test message to a specific partition.
        1. If you want to send the test message to a specific partition, click Yes and enter the partition ID in the Partition ID field, such as 0. For more information about how to query partition IDs, see View partition status.
        2. If you do not want to send the test message to a specific partition, click No.
      4. Use Message Queue for Apache Kafka SDKs or run docker commands to consume the test message as prompted.
    • Set the Method of Sending parameter to Docker and run a Docker container.
      1. Run the docker commands provided in the Run the Docker container to produce a sample message section to send the test message.
      2. Run the docker commands provided in the How do I consume a message after the message is sent? section to consume the test message.
    • Set the Method of Sending parameter to SDK, select a programming language or a framework, and then select an access method to use the corresponding SDK to send and consume messages.

View the partition status

After you send a message to the specified partition, view the partition status.

On the Topics page, find the topic whose partition status you want to view, and choose More > Partition Status in the Actions column.
Table 1. Partition status information
Parameter Description
Partition ID The ID of the partition in the topic.
Minimum Offset The minimum offset of messages that are consumed in the partition.
Maximum Offset The maximum offset of messages that are consumed in the partition.
Last Updated At The time when the last message in the partition is stored.
Partition Status tab

Query messages by offset

  1. Log on to the Message Queue for Apache Kafka console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance resides.
  3. On the Instances page, click the name of the instance that you want to manage.
  4. In the left-side navigation pane, click Message Query.
  5. On the Message Query page, select Search by offset from the Search Method drop-down list.
  6. Select a topic name from the Topic drop-down list and a partition from the Partition drop-down list, enter an offset in the Offset field, and then click Search.

    Messages that start from the specified offset are displayed. For example, if the specified partition and offset are both 5, the query results are messages that start from Offset 5 in Partition 5.

    Table 2. Parameters in the query results and supported operations
    GUI element Description
    Partition The ID of the partition in the topic to which the message is sent.
    Offset The offset of the message.
    Key The key of the message. The key is converted to a string.
    Value The value of the message. The value is converted to a string, which indicates the message content.
    Created At The timestamp of the producer when the message is sent or the value of the timestamp field that you specify in the ProducerRecord parameter.
    Note
    • If a value is specified for the timestamp field, the value is displayed.
    • If no value is specified for the timestamp field, the system time when the message is sent is displayed.
    • A value in the format of 1970/x/x x:x:x indicates that the timestamp field is set to 0 or an invalid value.
    • You cannot specify a value for the timestamp field on clients of Message Queue for Apache Kafka version 0.9 and earlier.
    Actions
    • Click Download Key: Download the key of the message.
    • Click Download Value: Download the content of the message.
    Notice
    • The Message Queue for Apache Kafka console displays a maximum of 1 KB of content for each queried message. The excess content of the message is omitted. If you need to view the complete message, download the message.
    • This operation is supported only for instances of Professional Edition.
    • You can download up to 10 MB of messages at a time. If the total size of the queried messages exceeds 10 MB, only the first 10 MB of message content can be downloaded.