Comments (4)
每一个partition在相同的groupId下同时只能被一个consumer消费,如果这个consumer挂了,其它consumer自动接管(在此之前是待命状态)。如果增加partition,那么其它consumer也会接管继续消费。 保证任何消息可被消费,同时却不会冲突。
如果有多个groupId,那么每个groupId之间的consumer并不冲突,各自消费,当前一个partition会被每一组groupId的一个消费。有多少groupId,那么这个partition就会被消费多少次。
from jafka.
那对Consumer分组的意义又在哪里呢?
能留个IM么?
from jafka.
上面原来没有写清楚,我重新更正了下上面的回答。QQ:四一零九43200
from jafka.
以下是2个Consumer
1、不同组,消费同一topic,始终只有一个Cosumber能收到消息。另一个Consumer Group的FetchRunnable线程状态一直为Wait.
2、停掉一个Consumer Group,另一个Consumer Group的FetchRunnable线程状态一直为Wait.
3、不同Group消费不同topic也不行,另一个Consumer Group的FetchRunnable线程状态一直为Wait. 如果Consumer2的goupid与Consumer1相同,则可以消费不同的topic.
Consumer2:
JafkaConsumer consumer2 = new JafkaConsumer("group-2", "101.37.19.118", 2181) {
@OverRide
protected void onMessage(JafkaMessage message) {
System.out.println("consumer 2 onMessage => " + message.getData().readUTF());
}
};
consumer2.addTopic("demo1").start();
Consumer1:
JafkaConsumer consumer1 = new JafkaConsumer("group-1", "101.37.19.118", 2181) {
@OverRide
protected void onMessage(JafkaMessage message) {
System.out.println("consumer 1 onMessage => " + message.getData().readUTF());
}
};
consumer1.addTopic("demo1").start();
from jafka.
Related Issues (20)
- 使用zk方式,如果生产端不断发送消息,相同组的消费端全停服,然后在起来,为什么收不到消息增加的消息了,还是有其他方式 HOT 8
- jafka的zk中broker信息存储的hostname和port,为什么不是ip:port HOT 2
- jafka实现了主备高可用机制了吗?
- 一次 Fetch 只能获取一个 LogSegment 的内容吗? HOT 1
- 是否支持分区备份及选 leader HOT 2
- Jafka#start(Properties, Properties, Properties) 方法判断有误 HOT 1
- 高吞吐量的实现机制是什么? HOT 2
- 关于 offsets 问题 HOT 1
- consumer的问题 HOT 13
- producer到broker消息质量级别仅仅支持‘At most once’这种级别吗
- EmbeddedConsumer 构造函数中 blackListTopics 取值错误 HOT 2
- Processor#run() 方法的改进的一个建议
- jafka 消息的存储地址 问题 HOT 1
- 还在维护吗?目前版本兼容于kafka的哪个版本? HOT 1
- 升级到Java 8+
- Is there any aarch64 config file under bin/ ? (jafka aarch64 配置文件支持)
- 支持集群模式吗,支持Topic副本吗
- 请问支持windows64位系统吗?如果不支持,该怎么做? HOT 1
- 测试用例的运行 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jafka.