You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Raghav Joshi <ra...@infoobjects.com> on 2015/06/19 10:24:31 UTC

Fwd: Spark Streaming + kakfa (Check that you get the data from kafka producer)

lines.foreachRDD(new Function<JavaRDD<String>, Void>() {
@Override
public Void call(JavaRDD<String> rdd) throws Exception {
List<String> collect = rdd.collect();
for (String data : collect) {
try {
// save data in the log.txt file
Path filePath = Paths
.get(rdd save file);
if (!Files.exists(filePath)) {
Files.createFile(filePath);
}
String temp = "Text to be added" + " data is " + data;
Files.write(filePath, temp.getBytes(),
StandardOpenOption.APPEND);
 } catch (IOException e) {
e.printStackTrace();
}
}
 return null;
}
});