0

How can set a trigger in Flink to perform some operation when a particular time has passed? Eg: Sum of the stream at 1 PM everyday

1 Answers1

1

A KeyedProcessFunction can use timers to trigger actions at specific times (on a per-key basis). These can be either processing time timers, which use system time, or they can be event time timers, which are triggered by Watermarks.

Here are examples of each, from the tutorials in the docs:

Also see the more detailed docs about process functions and timers.

Note that if you don't want to apply timers in a key-partitioned manner, but instead need to operate on the entire datastream (i.e., not in parallel), you can use keyBy(constant) to get yourself into a keyed context without actually partitioning the stream.

David Anderson
  • 39,434
  • 4
  • 33
  • 60
  • Does this make a window based on when the program started? I need that irrespective of the time that execution of program starts (sometime it may start at 11 AM, or it may start at 1 AM), the result always get calculated at 1 PM. – Abhinav Sharma Feb 02 '21 at 12:30
  • Here thse timers seems to time the event based on when the execution started. – Abhinav Sharma Feb 02 '21 at 12:31
  • Processing time timers are set relative to the epoch. They are not related to when the execution began. – David Anderson Feb 02 '21 at 14:17
  • This means that if You want to start timer always at 1AM, You need to get the current processing time and calculate what delay to use when registering the timer. – Dominik Wosiński Feb 02 '21 at 14:26