5-3socket建立datastream

小馬牛發表於2020-10-02
object DataStreamSourceApp {
  def main(args: Array[String]): Unit = {
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
    socketFunction(env)

    env.execute("DataStreamSourceApp")
  }

  def socketFunction(env: StreamExecutionEnvironment): Unit ={
    val data = env.socketTextStream("192.168.101.128",9999)
    data.print().setParallelism(1)
  }

}

To run the example program, start the input stream with netcat first from a terminal:

nc -lk 9999

相關文章