Kafka API实战

4KafkaAPI实战

1)启动zkkafka集群,在kafka集群中打开一个消费者

[hadoop102 kafka]$ bin/kafka-console-consumer.sh \ --zookeeper hadoop01:2181 --topic first

2)导入pom依赖

 

<dependencies>
   <!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients -->
<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka-clients</artifactId>
    <version>2.2.1</version>
</dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka -->
<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.12</artifactId>
    <version>2.2.1</version>
</dependency>

</dependencies>

 

4.2 Kafka生产者Java API

4.2.1 创建生产过时的API

 

posted @ 2019-07-29 02:32  DiYong  阅读(142)  评论(0编辑  收藏  举报