Kafka控制台工具生产者/消费者测试

时间:2018-05-23 20:30:04

标签: apache-kafka kafka-consumer-api

创建“测试”主题后,

kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 4 --topic test

我看到的内容已正确创建:

kafka-topics --describe --zookeeper localhost:2181 --topic test
Topic:test  PartitionCount:4    ReplicationFactor:1 Configs:
    Topic: test Partition: 0    Leader: 0   Replicas: 0 Isr: 0
    Topic: test Partition: 1    Leader: 0   Replicas: 0 Isr: 0
    Topic: test Partition: 2    Leader: 0   Replicas: 0 Isr: 0
    Topic: test Partition: 3    Leader: 0   Replicas: 0 Isr: 0

我有两个控制台窗口,一个Producer和一个Consumer控制台。 Producer适用于:

kafka-console-producer --broker-list localhost:9092 --topic test
>

当我在第二个控制台窗口上尝试以下操作时:

kafka-console-consumer –bootstrap-server localhost:9092 –from-beginning –topic test

我收到错误:

Exactly one of whitelist/topic is required.
Option                                   Description
------                                   -----------
--blacklist <String: blacklist>          Blacklist of topics to exclude from
                                           consumption.
...Lots more text here...

在控制台Producer中监听来自Consumer的邮件的正确方法是什么?

0 个答案:

没有答案