[
https://issues.apache.org/jira/browse/FLINK-3551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15692928#comment-15692928
]
ASF GitHub Bot commented on FLINK-3551:
---------------------------------------
Github user thvasilo commented on a diff in the pull request:
https://github.com/apache/flink/pull/2761#discussion_r89465547
--- Diff:
flink-examples/flink-examples-streaming/src/main/scala/org/apache/flink/streaming/scala/examples/kafka/WriteIntoKafka.scala
---
@@ -0,0 +1,81 @@
+/*
+ * 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.scala.examples.kafka
+
+import org.apache.flink.api.common.restartstrategy.RestartStrategies
+import org.apache.flink.api.java.utils.ParameterTool
+import org.apache.flink.streaming.api.functions.source.SourceFunction
+import
org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext
+import org.apache.flink.streaming.api.scala._
+import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer08
+import org.apache.flink.streaming.util.serialization.SimpleStringSchema
+
+/**
+ * Generate a String every 500 ms and write it into a Kafka topic
+ *
+ * Please pass the following arguments to run the example:
+ * --topic test --bootstrap.servers localhost:9092
+ *
+ */
+object WriteIntoKafka {
+
+ def main(args: Array[String]): Unit = {
+
+ // parse input arguments
+ val params = ParameterTool.fromArgs(args)
+
+ if (params.getNumberOfParameters < 2) {
+ println("Missing parameters!")
+ println("Usage: Kafka --topic <topic> --bootstrap.servers <kafka
brokers>")
+ return
+ }
+
+ val env = StreamExecutionEnvironment.getExecutionEnvironment
+ env.getConfig.disableSysoutLogging
+
env.getConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(4, 10000))
+
+ // very simple data generator
+ val messageStream = env.addSource(new SourceFunction[String]() {
+ var running = true
+
+ override def run(ctx: SourceContext[String]): Unit = {
+ var i = 0L
+ while (this.running) {
+ ctx.collect(s"Element - ${i}")
+ i += 1
+ Thread.sleep(500)
+ }
+ }
+
+ override def cancel(): Unit = running = false
+ })
+
+ // create a Kafka producer for Kafka 0.8.x
+ val kafkaProducer = new FlinkKafkaProducer08(
--- End diff --
As before any reason to keep using 0.8?
> Sync Scala and Java Streaming Examples
> --------------------------------------
>
> Key: FLINK-3551
> URL: https://issues.apache.org/jira/browse/FLINK-3551
> Project: Flink
> Issue Type: Sub-task
> Components: Examples
> Affects Versions: 1.0.0
> Reporter: Stephan Ewen
> Assignee: Lim Chee Hau
> Fix For: 1.0.1
>
>
> The Scala Examples lack behind the Java Examples
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)