Updated on 2023-11-30 GMT+08:00

Configuring Parameters

Procedure

  1. Configure access_key, secret_key, and project_id in the dms_kafka_client_jaas.conf file.

    The three parameters are used to authenticate DMS Kafka API requests.

    KafkaClient {
      com.huawei.middleware.kafka.sasl.client.KafkaLoginModule required
      access_key="XXXXXX"
      secret_key="XXXXXX"
      project_id="XXXXXX";
    };

    Replace them with the actual access_key, secret_key, and project_id of your account.

    To access the queues authorized by other tenants, set target_project_id to the project ID of the authorizing tenant.
    KafkaClient {
      com.huawei.middleware.kafka.sasl.client.KafkaLoginModule required
      access_key="XXXXXX"
      secret_key="XXXXXX"
      project_id="XXXXXX"
      target_project_id="";
    };

  2. Configure SASL access to start upon process using either of the following methods. In both methods, replace /path with the actual path name.

    1. Method 1: Configure the following JVM parameter to add the location of SASL configuration file:
      -Djava.security.auth.login.config=/path/kafka_client_jaas.conf
    2. Method 2: Add the following information to project code so that SASL access can start before Kafka Producer and Consumer start:
      System.setProperty("java.security.auth.login.config", "/path/kafka_client_jaas.conf");

  3. Add the following information to the consumer.properties file:

    connections.max.idle.ms=30000

  4. Configure key parameters in the consumer.properties/producer.properties file.

    Table 1 Key parameters in the consumer.properties/producer.properties file

    Parameter

    Description

    Setting

    bootstrap.servers

    IP address or domain name of the DMS server

    -

    ssl.truststore.location

    Path in which the client certificate client.truststore.jks is located

    /path/client.truststore.jks, where /path must be replaced with the actual path name

    ssl.truststore.password

    Client certificate password

    -

    security.protocol

    Security protocol

    SASL_SSL

    sasl.mechanism

    Service name

    DMS (Note: All letters in the entered service name must be capitalized.)

    For details about other Kafka parameters, visit the official Kafka website.

  5. Enable Kafka debug logging by modifying the log4j.properties file.

    log4j.rootLogger=DEBUG, stdout 
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c:%L)%n
    log4j.logger.org.apache.kafka.clients=DEBUG
    log4j.logger.kafka=INFO, stdout
    log4j.additivity.kafka=false
    log4j.logger.org.apache.kafka=DEBUG, stdout
    log4j.additivity.org.apache.kafka=false

  6. Write code. For details about APIs, visit the official Kafka website.