Viewing Sample Code of Kafka Production and Consumption

Distributed Message Service 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 image1 in the upper left corner to select a region.

    Note

    Select the region where your Kafka instance is located.

  3. Click Service List and choose Application > Distributed Message Service. The Kafka instance list is displayed.

  4. Click the desired Kafka instance to view the instance details.

  5. In the navigation pane, choose Topics.

  6. Click View Sample Code. The Sample Code dialog box is displayed.

    View sample code for creating and retrieving messages in Java, Go, and Python. Set Access By to PlainText to view the sample code where SASL_SSL authentication is disabled. Set Access By to SASL_SSL to view the sample code where SASL_SSL authentication is enabled.