./bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic testing
查看当前所有的主题列表
./bin/kafka-topics.sh --list --bootstrap-server localhost:9092
在第一个终端,我们通过生产者命令向指定服务器的指定主题发布消息,会打开一个交互式的输入,我们输入几个测试数据。
生产者发布消息:
./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testing
消费者接收消息:
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testing --from-beginning
全部评论