If an exception occurs on an instance in the running state, you can perform health self-check on the instance. This topic describes how to perform self-check.

Prerequisites

Test network connectivity

  1. Obtain an endpoint.
    1. Log on to the Message Queue for Apache Kafka console.
    2. In the Resource Distribution section of the Overview page, select the region where your instance resides.
    3. On the Instances page, click the name of the instance that you want to manage.
    4. On the Instance Details page, obtain an instance endpoint in the Endpoint Information section.
      endpoint
      Note For more information about the differences among endpoints, see Comparison among endpoints.
  2. In the directory where the self-check tool is located, run the system terminal executor and run the java -jar KafkaChecker.jar telnet -s endpoint command to test the connectivity to Message Queue for Apache Kafka.
    For example, if the client connects to the default endpoint of the Message Queue for Apache Kafka instance from a virtual private cloud (VPC), run the java -jar KafkaChecker.jar telnet -s 192.168.XX.XX:9092,192.168.XX.XX:9092,192.168.XX.XX:9092 command.
    If information similar to the output shown in the following figure is displayed, the network connection is normal. VPC
    If information similar to the output shown in the following figure is displayed, the IP addresses have not been added to the whitelist of the endpoint of the Message Queue for Apache Kafka instance. For more information, see Configure the whitelist. WhiteList

Test message sending

Note If a message is sent, real test data is generated. You must create a topic for self-check to prevent negative impact on real business data.
Run the command that corresponds to the network access mode to send messages.
  • Connect to the default endpoint through port 9092 from a VPC: java -jar KafkaChecker.jar send -s IP address of the endpoint:9092 --topic topic name.

    Example: java -jar KafkaChecker.jar send -s 192.168.XX.XX:9092 --topic test

  • Connect to the SSL endpoint through port 9093 over the Internet. SASL allows you to use the PLAIN or SCRAM-SHA-256 mechanism for identity authentication. You must run the command that corresponds to the identity authentication mechanism to send messages.
    Note On the Internet, the default SASL user of a Message Queue for Apache Kafka instance uses the PLAIN mechanism for identity authentication. When you create an SASL user to implement fine-grained permission control, you can set the identity authentication mechanism to PLAIN or SCRAM-SHA-256. For more information, see Grant permissions to SASL users. You must run the command that corresponds to the identity authentication mechanism to send messages.
    • PLAIN mechanism: java -jar KafkaChecker.jar send -sm PLAIN -ss true -u username-psw password -s IP address of the endpoint:9093 --topic topic name

      Example: java -jar KafkaChecker.jar send -sm PLAIN -ss true -u test -psw test**** -s 192.51.XX.XX:9093 --topic test

    • SCRAM-SHA-256 mechanism: java -jar KafkaChecker.jar send -sm SCRAM-SHA-256 -ss true -u username -psw password -s IP address of the endpoint:9093 --topic topic name

      Example: java -jar KafkaChecker.jar send -sm SCRAM-SHA-256 -ss true -u test -psw test**** -s 192.51.XX.XX:9093 --topic test

  • Connect to the SASL endpoint through port 9094 from a VPC. SASL allows you to use the PLAIN or SCRAM-SHA-256 mechanism for identity authentication. You must run the command that corresponds to the identity authentication mechanism to send messages.
    • PLAIN mechanism: java -jar KafkaChecker.jar send -sm PLAIN -sp true -u username -psw password -s IP address of the endpoint:9094 --topic topic name

      Example: java -jar KafkaChecker.jar send -sm PLAIN -sp true -u test -psw test**** -s 192.168.XX.XX:9094 --topic test

    • SCRAM-SHA-256 mechanism: java -jar KafkaChecker.jar send -sm SCRAM-SHA-256 -sp true -u username -psw password -s IP address of the endpoint:9094 --topic topic name

      Example: java -jar KafkaChecker.jar send -sm SCRAM-SHA-256 -sp true -u test -psw test**** -s 192.168.XX.XX:9094 --topic test

If information similar to the output shown in the following figure is returned, the messages are sent. result

Test message consumption

Run the command that corresponds to the network access mode to consume messages.
  • Connect to the default endpoint through port 9092 from a VPC: java -jar KafkaChecker.jar pull -s IP address of the endpoint:9092 --topic topic name --group group name --partition 0 --offset 0 --count 10.

    Example: java -jar KafkaChecker.jar pull -s 192.168.XX.XX:9092 --topic test --group test --partition 0 --offset 0 --count 10

  • Connect to the SSL endpoint through port 9093 over the Internet. SASL allows you to use the PLAIN or SCRAM-SHA-256 mechanism for identity authentication. You must run the command that corresponds to the identity authentication mechanism to consume messages.
    Note On the Internet, the default SASL user of a Message Queue for Apache Kafka instance uses the PLAIN mechanism for identity authentication. When you create an SASL user to implement fine-grained permission control, you can set the identity authentication mechanism to PLAIN or SCRAM-SHA-256. For more information, see Grant permissions to SASL users. You must run the command that corresponds to the identity authentication mechanism to consume messages.
    • PLAIN mechanism: java -jar KafkaChecker.jar pull -sm PLAIN -ss true -u username -psw password -s IP address of the endpoint:9093 --topic topic name --group group name --partition 0 --offset 0 --count 10

      Example: java -jar KafkaChecker.jar pull -sm PLAIN -ss true -u test -psw test**** -s 192.51.XX.XX:9093 --topic test --group test --partition 0 --offset 0 --count 10

    • SCRAM-SHA-256 mechanism: java -jar KafkaChecker.jar pull -sm SCRAM-SHA-256 -ss true -u username -psw password -s IP address of the endpoint:9093 --topic topic name --group group name --partition 0 --offset 0 --count 10

      Example: java -jar KafkaChecker.jar pull -sm SCRAM-SHA-256 -ss true -u test -psw test**** -s 192.51.XX.XX:9093 --topic test --group test --partition 0 --offset 0 --count 10

  • Connect to the SASL endpoint through port 9094 from a VPC. SASL allows you to use the PLAIN or SCRAM-SHA-256 mechanism for identity authentication. You must run the command that corresponds to the identity authentication mechanism to consume messages.
    • PLAIN mechanism: java -jar KafkaChecker.jar pull -sm PLAIN -sp true -u username -psw password -s IP address of the endpoint:9094 --topic topic name --group group name --partition 0 --offset 0 --count 10

      Example: java -jar KafkaChecker.jar pull -sm PLAIN -sp true -u test -psw test**** -s 192.168.XX.XX:9094 --topic test --group test --partition 0 --offset 0 --count 10

    • SCRAM-SHA-256 mechanism: java -jar KafkaChecker.jar pull -sm SCRAM-SHA-256 -sp true -u username -psw password -s IP address of the endpoint:9094 --topic topic name --group group name --partition 0 --offset 0 --count 10

      Example: java -jar KafkaChecker.jar pull -sm SCRAM-SHA-256 -sp true -u test -psw test**** -s 192.168.XX.XX:9094 --topic test --group test --partition 0 --offset 0 --count 10

If information similar to the output shown in the following figure is displayed, the messages are consumed. consumer

Verify the demo

If the preceding tests succeed, use the demo to send and consume messages to address the issue of your client code. Download the code package of your development language as required. For more information, see Overview.