The API for the Lindorm streaming engine is fully compatible with the API for open source Apache Kafka. You can use an open source Apache Kafka script tool to connect to the Lindorm streaming engine. This topic describes how to use an open source Apache Kafka script tool to connect to the Lindorm streaming engine.
Prerequisites
Java Development Kit (JDK) V1.7 or later is installed.
The IP address of your client is added to the whitelist of the ApsaraDB for Lindorm (Lindorm) instance. For more information, see Configure a whitelist.
The value of Lindorm Stream Kafka Endpoint is obtained. For more information, see View endpoints.
NoteLindorm Stream Kafka Endpoint specifies a virtual private cloud (VPC) endpoint of your Lindorm streaming engine. Make sure that your application and your Lindorm instance are deployed in the same VPC.
Procedure
Click here to download an open source Apache Kafka script tool.
Decompress the downloaded open source Apache Kafka script tool.
tar -zxf kafka_2.12-2.7.1.tgz cd kafka_2.12-2.7.1
Create a topic.
./bin/kafka-topics.sh --bootstrap-server <Lindorm Stream Kafka Endpoint> --topic <Topic Name> --partitions <Number of Partitions> --create
View all existing topics.
./bin/kafka-topics.sh --bootstrap-server <Lindorm Stream Kafka Endpoint> --list
Delete a topic. If you delete a topic, data in the topic is also deleted.
./bin/kafka-topics.sh --bootstrap-server <Lindorm Stream Kafka Endpoint> --topic <Topic Name> --delete
Read data from a topic.
./bin/kafka-console-consumer.sh --bootstrap-server <Lindorm Stream Kafka Endpoint> --topic <Topic Name> --from-beginning --max-messages <Number of Messages to Read>
Write data to a topic.
./bin/kafka-console-producer.sh --bootstrap-server <Lindorm Stream Kafka Endpoint> --topic <Topic Name>
Query the consumption status of a consumer group.
./bin/kafka-consumer-groups.sh --bootstrap-server <Lindorm Stream Kafka Endpoint> --group <Group Name> --describe