问题
i have one situation here.
I want that my aplication connect one time to kafka, read the offset, make an action and then stop the application.
I was reading about StreamingListener for detect when the first iteration occurs.
i don´t know how use StreamingListener to stop mi application. can you help me?
I am using spark 1.4
Example code bellow:
val lines = KafkaUtils.createStream(ssc, zkQuorum, group, topicMap).map(_._2)
lines.foreachRDD( rdd => {
rdd.saveAsTextFile("......")
})
sys.ShutdownHookThread {
println("Gracefully stopping Spark Streaming Application")
ssc.stop(true, true)
println("Application stopped")
}
ssc.start()
ssc.awaitTermination()
thanks!
来源:https://stackoverflow.com/questions/36778566/how-to-use-spark-streaming-kafka-with-streaminglistener