• Distributed Message Service

dms
  1. Help Center
  2. Distributed Message Service
  3. Developer Guide
  4. Creating a Project

Creating a Project

This section uses the Maven project kafkademo as an example to describe how to create a project.

Procedure

  1. Download the demo package.

    1. Log in to the DMS console.
    2. In the navigation pane, choose Using APIs.
    3. Choose Kafka Basic.
    4. Click Download Sample Code to download the demo package KafkaDemo.zip.

  2. Click Download SDK to download the DMS Kafka SASL package.

    Decompress the following directories from the package:

    • client.truststore.jks: client certificate
    • dms.kafka.sasl.client-1.0.0.jar: DMS Kafka SASL package
    • dms_kafka_client_jaas.conf: client configuration file

    You can also decompress the SDK package from KafkaDemo.zip (the location is KafkaDemo\dist\libs\dms.kafka.sasl.client-1.0.0.jar).

  3. On Eclipse (the recommended version is 4.6 or later), create a Maven project. The project name kafkademo is used as an example.

    Figure 1 Creating a Maven project

  4. Click Finish.
  5. Import the DMS Kafka SASL package dms.kafka.sasl.client-1.0.0.jar.

    1. Right-click the new project kafkademo, and create a libs folder.
    2. Copy dms.kafka.sasl.client-1.0.0.jar to libs.
    3. Add the following information to the pom.xml file to import dms.kafka.sasl.client-1.0.0.jar into the Maven repository:
      <dependency> 
           <groupId>dms</groupId> 
           <artifactId>kafka.sasl.client</artifactId> 
           <version>1.0.0</version> 
           <scope>system</scope> 
           <systemPath>${project.basedir}/libs/dms.kafka.sasl.client-1.0.0.jar</systemPath> 
       </dependency> 
       <dependency> 
           <groupId>org.apache.kafka</groupId> 
           <artifactId>kafka-clients</artifactId> 
           <version>0.10.2.1</version> 
       </dependency> 
       <dependency> 
           <groupId>org.slf4j</groupId> 
           <artifactId>slf4j-api</artifactId> 
           <version>1.7.7</version> 
       </dependency> 
       <dependency> 
           <groupId>org.slf4j</groupId> 
           <artifactId>slf4j-log4j12</artifactId> 
           <version>1.7.7</version> 
       </dependency> 
       <dependency> 
           <groupId>log4j</groupId> 
           <artifactId>log4j</artifactId> 
           <version>1.2.17</version> 
       </dependency>     
    4. Save the pom.xml file.