Updated on 2024-04-02 GMT+08:00

Consumer Sample Commissioning

Prerequisites

  • Ensure that Windows is configured to allow Kafka access through an EIP if you need to debug applications on Windows. For details, see Kafka Access Configuration on Windows Using EIPs.
  • Ensure that the current user has the read permission on all files in the src/main/resources directory and the dependent library file directory if you need to debug applications on Linux. Ensure that the JDK has been installed and Java environment variables have been set.

Commissioning Applications on Windows

  1. Ensure that the mappings between the host names and service IP addresses of all the hosts in the remote cluster are configured in the local hosts file.
  2. Run Consumer.java on IntelliJ IDEA, as shown in Figure 1.

    Figure 1 Running Consumer.java

  3. Click Run. In the displayed console window, you can see that Producer starts after Consumer has started and you can view the messages received in real time.

    Figure 2 Consumer.java running window

Commissioning Applications on Linux

  1. Compile and generate a JAR package, and copy the JAR package to the src/main/resources directory at the same level as the dependent library folder. For details, see Commissioning Applications on Linux.
  2. Run the following command to run the consumer sample project:

    java -cp /opt/client/lib/*:/opt/client/src/main/resources com.huawei.bigdata.kafka.example.Consumer