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.
- 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.
- 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.
- 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.
- 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
- In Windows, open the CLI in the D:\Spring directory and run the following command:
- 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
- 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.
- 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
- 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.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot