代码:
import java.util.Properties
import org.apache.flink.api.common.serialization.SimpleStringSchema
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer011
//温度传感器读取样例类
case class SensorReading(id: String, timestamp: Long, temperature: Double)
object SourceTest {
def main(args: Array[String]): Unit = {
val env = StreamExecutionEnvironment.getExecutionEnvironment
//1.从自定义的集合中读取数据
import org.apache.flink.api.scala._
// val stream1 = env.fromCollection(List(SensorReading("sensor_1", 1547718199, 35.80018327300259),
// SensorReading("sensor_6", 1547718201, 15.402984393403084),
// SensorReading("sensor_7", 1547718202, 6.720945201171228),
// SensorReading("sensor_10", 1547718205,