Help Center/ Distributed Message Service for Kafka/ User Guide/ Managing Instances/ Viewing Sample Code of Kafka Production and Consumption
Updated on 2025-02-14 GMT+08:00

Viewing Sample Code of Kafka Production and Consumption

Distributed Message Service for Kafka allows you to view sample Java, Go, and Python code of producing and consuming messages on the console. You can quickly complete Kafka client integration.

Procedure

  1. Log in to the console.
  2. Click in the upper left corner to select the region where your instance is located.
  3. Click and choose Application > Distributed Message Service (for Kafka) to open the console of DMS for Kafka.
  4. Click the desired instance to go to the instance details page.
  5. In the navigation pane, choose Topics.
  6. Click View Sample Code. The Sample Code dialog box is displayed.

    The sample code is available in Java, Go, and Python, and PlainText, SASL_SSL, and SASL_PLAINTEXT access modes.

    • PlainText: Accessing the Kafka instance in plaintext.
    • SASL_SSL: Accessing the Kafka instance in ciphertext with SASL authentication. SASL authentication uses PLAIN or SCRAM-SHA-512.
    • SASL_PLAINTEXT: Accessing the Kafka instance in plaintext with SASL authentication. SASL authentication uses PLAIN or SCRAM-SHA-512.