I am working with apache flink v1.4 and we want to fire our window using event time.
I have made sure that:
Time Characteristic have been set
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
is presentI am assigning the watermarks using following code
deviceVnetSource.assignTimestampsAndWatermarks(WatermarkStrategy.<DataEngineMessage<String, DeviceVnet>>forMonotonousTimestamps().withTimestampAssigner((event,timestamp)-> event.getValue().getTsSec() * 1000))
Time Value is in milliseconds
In the Sink Function I see following output when events are passed (my watermark time is increasing)
-
TestSinkFunction - watermark time - -9223372036854775808 TestSinkFunction - watermark time - 1674113291999 TestSinkFunction - watermark time - 1674113292999 TestSinkFunction - watermark time - 1674113301999 TestSinkFunction - watermark time - 1674113319999
But My Window function is not triggering which is set to 2 seconds.
Can someone please tell me where I am going wrong?
This is how entire pipeline looks like -
public class FlinkJob {
@Autowired
StreamExecutionEnvironment env;
private void runJob() throws Exception {
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
var deviceVnetSource =
streamClient.streamFromTopic(Constants.DEVICEVNET_SOURCE_TOPIC,
"DeviceVnet Source");
var unifiedDistanceStream =
deviceVnetSource.assignTimestampsAndWatermarks(WatermarkStrategy.
<DataEngineMessage<String, DeviceVnet>>forMonotonousTimestamps()
.withTimestampAssigner((event,timestamp)->
event.getValue().getTsSec() * 1000))
//.keyBy(key -> key.getKey())
//.window(TumblingEventTimeWindows.of(Time.seconds(1))) This window is not triggering at all
//.process(new UnifiedDistanceOperatorTest())
.addSink(new TestSinkFunction());
}
}