kafka基本概念和hello world搭建

2019-08-28  本文已影响0人  powerjiajun

什么是kafka?

Kafka是由Apache软件基金会开发的一个开源流处理平台,由ScalaJava编写。Kafka是一种高吞吐量的分布式发布订阅消息系统,它可以处理消费者在网站中的所有动作流数据。
简单地说就是一个实现消息的发送与高效消费的一个消息中间件。

kafka可以帮助我们做什么?或者是解决什么问题?

5步快速搭建一个kafka的hello world

1.首先按这篇博文指向的文档把kafka安装包下载好后,启动好zookeeper和kafka实例。
kafka快速安装

2.进入kafka安装目录,创建一个名为test的topic。

bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test

3.开启一个消费者,监听test。

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

4.向名为test的topic发送消息。

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
This is a message
This is another message

5.消费者已经输出了刚才发送的消息,hello world实例搭建完成。

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
This is a message
This is another message
上一篇 下一篇

猜你喜欢

热点阅读