tree: b6ea3c05ea563292f18f858e78f3cf063ec2e313 [path history] [tgz]
  1. src/
  2. pom.xml
  3. readme.md
example/kafka/readme.md

Kafka-IoTDB Demo

Function

The example is to show how to send data from localhost to IoTDB through Kafka.

Usage

Version usage

IoTDB: 0.14.0-SNAPSHOT
Kafka: 2.8.0

Dependencies with Maven

<dependencies>
         <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_2.13</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.iotdb</groupId>
            <artifactId>iotdb-session</artifactId>
            <version>0.14.0-SNAPSHOT</version>
        </dependency>
</dependencies>

Launch the servers

  Before you run the program, make sure you have launched the servers of Kafka and IoTDB.
  For details, please refer to http://kafka.apache.org/081/documentation.html#quickstart

Run Producer.java

  The class is to send data from localhost to Kafka clusters.
  Firstly, you have to change the parameter of TOPIC in Constant.java to what you create:(for example : "Kafka-Test")
  > public final static String TOPIC = "Kafka-Test";
  The default format of data is "device,timestamp,value ". (for example : "measurement1,2017/10/24 19:30:00,60")
  Then you need to create data in Constat.ALL_DATA
  Finally, run KafkaProducer.java

Run Consumer.java

  The class is to show how to consume data from kafka through multi-threads.
  The data is sent by class KafkaProducer.
  You can set the parameter of CONSUMER_THREAD_NUM in Constant.java to make sure the number of consumer threads:(for example: "3")
  > private final static int CONSUMER_THREAD_NUM = 3;

Notice

 If you want to use multiple consumers, please make sure that the number of topic's partition you create is more than 1.