All Products
Search
Document Center

Lindorm:Use an open source Apache Kafka script tool to connect to the Lindorm streaming engine

Last Updated:Apr 11, 2023

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.

    Note

    Lindorm 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

  1. Click here to download an open source Apache Kafka script tool.

  2. 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
  3. Create a topic.

    ./bin/kafka-topics.sh --bootstrap-server <Lindorm Stream Kafka Endpoint> --topic <Topic Name> --partitions <Number of Partitions> --create
  4. View all existing topics.

    ./bin/kafka-topics.sh --bootstrap-server <Lindorm Stream Kafka Endpoint> --list
  5. 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
  6. 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>
  7. Write data to a topic.

    ./bin/kafka-console-producer.sh --bootstrap-server <Lindorm Stream Kafka Endpoint> --topic <Topic Name>
  8. Query the consumption status of a consumer group.

    ./bin/kafka-consumer-groups.sh --bootstrap-server <Lindorm Stream Kafka Endpoint> --group <Group Name> --describe