之前的方案是用flume来做过滤,但是现在的考虑是去掉多余的技术栈,想用kafka直接实现,有scala/java的例子吗?
```shell
import scala.sys.process._
def someProcessing(line: String): Unit = {
// do whatever you want with that line
print("[just read this line] ")
println(line)
}
// the file to read
val file = "mylogfile.txt"
// the process to start
val tail = Seq("tail", "-f", file)
// continuously read lines from tail -f
tail.lineStream.foreach(someProcessing)
// careful: this never returns (unless tail is externally killed)
````
这是我在stackoverflow上看到的,但是这个不能被打断恢复。