Hi All,
We're using the provided high level consumers (kafka.consumer.Consumer) and
i'm was wondering how common or smart it would be to have one Consumer
consume messages from multiple topics, something like:
ImmutableMap<String, Integer> topics = ImmutableMap.of("topic1", 3,
"topic2", 2, "topic3", 5);
Map<String, List<KafkaStream<Message>>> topicMessageStreams =
connector.createMessageStreams(topics);
ExecutorService executor = Executors.newFixedThreadPool(3+2+5);
for (final List<KafkaStream<Message>> topicStreams :
topicMessageStreams.values()) {
for(final KafkaStream<Message> stream: topicStreams) {
executor.submit(new Runnable() {
public void run() {
for(MessageAndMetadata msgAndMetadata: stream) {
// do stuff
}
}
});
}
}
Any reason this would be a really bad idea?
Much appreciated,
Matan