在命令行中在Kafka中创建多个使用者 [英] Create multiple consumers in Kafka in command line

查看:76
本文介绍了在命令行中在Kafka中创建多个使用者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Kafka的新朋友.当我在命令行中运行快速入门示例时,发现无法在命令行中创建多个使用者.

I'm new in Kafka. When I was running the quick start example in command line, I found I can't create multiple consumers in command line.

条件:

我建立了一个名为test的主题,该主题具有3个分区,并且我还为此主题构建了一个生产器.

I built a topic named test with 3 partitions, and I also built a producer on this topic.

然后我想创建两个不同的使用者,在这个主题上共享一个名为test1的相同使用者组.

Then I wanted to create two different consumers sharing a same consumer-group named test1 on this topic.

我按如下所示两次运行了命令:

I ran the command like below twice:

   bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --group test1

第一个运行,但是当我第二次运行时,第一个将断开连接,而第二个运行.

The first one worked but when I ran the second time the first one would disconnect and the second one worked.

那么如何在命令行的同一使用者组中创建两个或多个使用者?

So how can I create two or more consumers in a same consumer group in command line?

    WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1146)

推荐答案

除了像secfree的答案一样使用-consumer.config 选项之外,您还可以使用

Besides using --consumer.config option like the secfree's answer, you can also use

-消费者属性group.id =您的组

在不编辑配置文件的情况下指定组名的选项.

option to specify a group name without editing the config file.

这篇关于在命令行中在Kafka中创建多个使用者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆