pnowojski commented on a change in pull request #7081: [FLINK-10853] Provide 
end-to-end test for Kafka 0.9 connector
URL: https://github.com/apache/flink/pull/7081#discussion_r233819862
 
 

 ##########
 File path: 
flink-examples/flink-examples-streaming-kafka-0.9/src/main/java/org/apache/flink/streaming/examples/kafka/Kafka09Example.java
 ##########
 @@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.streaming.examples.kafka;
+
+import org.apache.flink.api.java.utils.ParameterTool;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer09;
+import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer09;
+import org.apache.flink.streaming.examples.kafka.base.CustomWatermarkExtractor;
+import org.apache.flink.streaming.examples.kafka.base.KafkaEvent;
+import org.apache.flink.streaming.examples.kafka.base.KafkaEventSchema;
+import org.apache.flink.streaming.examples.kafka.base.KafkaExampleUtil;
+import org.apache.flink.streaming.examples.kafka.base.RollingAdditionMapper;
+
+/**
+ * A simple example that shows how to read from and write to Kafka. This will 
read String messages
+ * from the input topic, parse them into a POJO type {@link KafkaEvent}, group 
by some key, and finally
+ * perform a rolling addition on each key for which the results are written 
back to another topic.
+ *
+ * <p>This example also demonstrates using a watermark assigner to generate 
per-partition
+ * watermarks directly in the Flink Kafka consumer. For demonstration 
purposes, it is assumed that
+ * the String messages are of formatted as a (word,frequency,timestamp) tuple.
+ *
+ * <p>Example usage:
+ *     --input-topic test-input --output-topic test-output --bootstrap.servers 
localhost:9092 --zookeeper.connect localhost:2181 --group.id myconsumer
+ */
+public class Kafka09Example {
+
+       public static void main(String[] args) throws Exception {
+               // parse input arguments
+               final ParameterTool parameterTool = 
ParameterTool.fromArgs(args);
+               StreamExecutionEnvironment env = 
KafkaExampleUtil.prepareExecutionEnv(parameterTool);
+
+               DataStream<KafkaEvent> input = env
+                               .addSource(
+                                       new FlinkKafkaConsumer09<>(
+                                               
parameterTool.getRequired("input-topic"),
+                                               new KafkaEventSchema(),
+                                               parameterTool.getProperties())
+                                       .assignTimestampsAndWatermarks(new 
CustomWatermarkExtractor()))
+                               .keyBy("word")
+                               .map(new RollingAdditionMapper());
+
+               input.addSink(
+                               new FlinkKafkaProducer09<>(
+                                               
parameterTool.getRequired("output-topic"),
+                                               new KafkaEventSchema(),
+                                               parameterTool.getProperties()));
+
+               env.execute("Kafka 0.11 Example");
 
 Review comment:
   copy/paste typo `env.execute("Kafka 0.9 Example");`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to