Updated on 2026-06-29 GMT+08:00

SpringBoot Sample Commissioning

This section applies to MRS 3.3.0 and later versions.

The kafka-springboot-examples sample code supports JDK 8, JDK 17.

  1. Enable Kafka Plain authentication.

    Log in to FusionInsight Manager, choose Cluster > Services > Kafka and choose Configurations > All Configurations. Search for sasl.enabled.mechanisms, change the value to GSSAPI,PLAIN, Click Save, click Dashboard, click More, and select Restart Service to make the configuration take effect.

  2. Obtain the huawei-spring-boot-kafka-examples-*.jar package.

    Find the POM file in the springboot/kafka-examples directory of the sample code, and use the Maven install tool to compile the Spring Boot sample in the same directory as the POM file. A target folder is generated, and huawei-spring-boot-kafka-examples-*.jar is obtained from the target folder.

  3. Create a directory on Windows or Linux as the running directory.

    • Create the D:\Spring directory in the Windows OS and upload the huawei-spring-boot-kafka-examples-*.jar and application.properties files to the current directory.
    • Create the /opt/spring directory on the Linux OS and upload the huawei-spring-boot-kafka-examples-*.jar and application.properties files to the current directory.

  4. Run the corresponding command to start Spring Boot:

    • In Windows, open the CLI in the D:\Spring directory and run the following command:

      java -jar huawei-spring-boot-kafka-examples-2.8.1-SNAPSHOT.jar

    • In Linux, run the following command in the /opt/spring directory:

      java -jar huawei-spring-boot-kafka-examples-2.8.1-SNAPSHOT.jar

  5. Produce data.

    • For a Windows OS, open a browser and enter http://IP address bound during Spring Boot startup:Port bound during Spring Boot startup/produce to generate data to Broker, as shown in the following figure.
      Figure 1 Producing data
    • For a Linux OS, run the curl command to access Spring Boot.

      curl http://IP address bound during Spring Boot startup:Port bound during Spring Boot startup/produce

  6. Consume data.

    • For a Windows OS, open a browser and enter http://IP address bound during Spring Boot startup:Port bound during Spring Boot startup/consume to consume data from broker, as shown in the following figure.
      Figure 2 Consuming data
    • For a Linux OS, run the curl command to access Spring Boot.

      curl http://IP address bound during Spring Boot startup:Port bound during Spring Boot startup/consume