[英]Kafka Consumer - Java Client
我在kafka消費者文檔中看到了此注釋-
由於存在許多分區,因此仍然可以平衡許多使用者實例上的負載。 但是請注意,使用者實例不能超過分區。
一個主題有50個分區。 如果我給a_numThreads值設置為50,則從每個分區中提取1條消息? 以上消息是否表示我在任何時候都不能創建超過50個線程?
public void run(int a_numThreads) {
Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
topicCountMap.put(topic, new Integer(a_numThreads));
Map<String, List<KafkaStream<byte[], byte[]>>> consumerMap = consumer.createMessageStreams(topicCountMap);
List<KafkaStream<byte[], byte[]>> streams = consumerMap.get(topic);
// now launch all the threads
//
executor = Executors.newFixedThreadPool(a_numThreads);
// now create an object to consume the messages
//
int threadNumber = 0;
for (final KafkaStream stream : streams) {
executor.submit(new ConsumerTest(stream, threadNumber));
threadNumber++;
}
}
您正在執行a_numThreads = 50
然后Executors.newFixedThreadPool(a_numThreads);
是的,這意味着您至少在任何時候都不能使用該執行器創建超過50個線程。
什么是文件的意思是,一個分區只能分配給1流,如果你不是創建50流創建51流后者會得到什么作為解釋這里
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.