1.需求:
测试同一个消费者组中的消费者,同一时刻只能有一个消费者消费。
2.案例实操
(1)在hadoop2、hadoop3上修改/opt/module/kafka-2.11/config/consumer.properties配置文件中的group.id属性为任意组名。
vi consumer.properties
group.id=movle

(2)再hadoop3、hadoop4上分别启动消费者
./bin/kafka-console-consumer.sh --bootstrap-server hadoop2:9092 --topic topic0519 --consumer.config config/consumer.properties
./bin/kafka-console-consumer.sh --bootstrap-server hadoop2:9092 --topic topic0519 --consumer.config config/consumer.properties
(3)在hadoop2上启动生产者
bin/kafka-console-producer.sh --broker-list hadoop2:9092 --topic topic0519
>hello world
(4)查看bigdata11和bigdata12的接收者。
同一时刻只有一个消费者接收到消息。



网友评论