flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sendoh <unicorn.bana...@gmail.com>
Subject Iterate several kafka topics using the kafka connector
Date Thu, 23 Jun 2016 12:33:20 GMT
Hi Flink developers,

Can I ask how could we iterate several Kafka topics using the Kafka

Our idea is like the following example:

List<DataStream&lt;JSONObject>> streams = new ArrayList<>();

// Iterate kafka topics
Iterator<String> topicIter = topicList.iterator();

        while (topicIter.hasNext()){

            String topic = topicIter.next();

            streams.add(env.addSource(new FlinkKafkaConsumer09<>(topic,
                    new JSONSchema(), properties)).rebalance());


Our goal is to union several kafka data streams into one, given the topics
as a list:

        Iterator<DataStream&lt;JSONObject>> streamsIt = streams.iterator();

        DataStream<JSONObject> currentStream = streamsIt.next();
            DataStream<JSONObject> nextStream = streamsIt.next();
            currentStream = currentStream.union(nextStream);



View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Iterate-several-kafka-topics-using-the-kafka-connector-tp7673.html
Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.

View raw message