You need to enable JavaScript to run this app.
Message Queue for Kafka

Message Queue for Kafka

Copy page
Download PDF
Connect instance
Connect to instance by using PLAINTEXT endpoint
Copy page
Download PDF
Connect to instance by using PLAINTEXT endpoint
This topic describes the steps to connect to a Kafka instance via the PLAINTEXT endpoint in a VPC network environment to generate and consume messages.​
Background information​
Message Queue for Kafka provides a common access method of PLAINTEXT protocol, i.e., the default endpoint. When connecting to the instance via the PLAINTEXT endpoint in a VPC network environment, no username or password is required. You can access the instance directly.​
Prerequisites​
  • PLAINTEXT endpoint information including connection address and port number is obtained. For detailed information, refer to View endpoint.​
  • A Topic is created. For action steps, refer to Create Topic.​
  • VolcanoEngine ECS is purchased, with JDK successfully installed and environment variables configured. Kafka open-source clients are downloaded, such as Kafka 2.2.2 client.​
Generate message​
  1. Extract the Kafka client files.​
  1. Open a terminal in the ./bin directory.​
  1. Run the following command to start the producer and begin generating messages.​
  • ​
    bash kafka-console-producer.sh --broker-list ${default endpoint} --topic ${Topic Name} ​
    ​
  • ​
    Parameters​
    Description​
    Default endpoint​
    It is the PLAINTEXT endpoint information obtained from the console instance details page. PLAINTEXT endpoints only support VPC access.​
    Topic Name​
    The topic name of Kafka instance.​
    ​
  1. Enter the message content to produce, and then press Enter to send the message to the Kafka instance.​
  • The content that is entered in each line will be packaged into a message and sent to the Kafka instance. To stop producing, use Ctrl+C to exit message production.​
  • ​
    [root@kafkaecs bin]# bash kafka-console-producer.sh --broker-list kafka-cnngc7an0qpv****.kafka.ivolces.com:9092 --topic mytopic​
    >Hello world!​
    >This is a Kafka message!​
    >^C[root@kafkaecs bin]#​
    ​
Consume messages​
  1. Open another terminal and run the following command to consume messages.​
  • To stop consuming, use the Ctrl+C command to exit message consumption.​
  • ​
    bash kafka-console-consumer.sh --bootstrap-server ${default endpoint} --topic ${Topic name} --group ${consumer group name} --from-beginning​
    ​
  • ​
    Parameters​
    Description​
    Default endpoint​
    PLAINTEXT endpoint information obtained from the console instance details page. PLAINTEXT endpoints only support VPC access.​
    Topic Name​
    The Topic name of Kafka instance.​
    Consumer Group Name​
    The name of custom consumer group​
    If you specified the consumer group name in the configuration file, ensure that the same name is configured in the command line. Otherwise, consumption may fail.​
    ​
  1. After successful operation, the consumer can receive messages sent by the producer. The messages are identical to the messages on the producer side.​
  • ​
    [root@kafka bin]# bash kafka-console-consumer.sh --bootstrap-server kafka-cnngc7an0qpv****.kafka.ivolces.com:9092 --topic mytopic --group grouptest --from-beginning​
    Hello world!​
    This is a Kafka message!​
    ^CProcessed a total of 2 messages​
    [root@kafka bin]#​
    ​
​
Last updated: 2025.08.08 18:39:48