flink 1.11定义watermark 水位线 水印 新方法 替代过时assignTimestampsAndWatermarks方法

mapStream
.assignTimestampsAndWatermarks(WatermarkStrategy.forBoundedOutOfOrderness(Duration.ofSeconds(3))
.withTimestampAssigner(new SerializableTimestampAssigner[(Long, student)] {
override def extractTimestamp(element: (Long, student), recordTimestamp: Long): Long = element._1
}
)

补充 2020年9月10日21:53:23 ,喜欢的话点个赞喔,大家的点赞就是我最大的动力!

import java.time.Duration
    import org.apache.flink.api.common.eventtime.{SerializableTimestampAssigner, WatermarkStrategy}
    val newDS= stream
      .assignTimestampsAndWatermarks(WatermarkStrategy.forBoundedOutOfOrderness(Duration.ofSeconds(3))
        .withTimestampAssigner(new SerializableTimestampAssigner[(Long,  String,String)] {
          override def extractTimestamp(element: (Long,  String,String), recordTimestamp: Long): Long = element._1
        }
        ))

你可能感兴趣的:(flink)