Hey all, I have a streaming use-case where I woul...
# troubleshooting
g
Hey all, I have a streaming use-case where I would like to implement a custom window function in Flink where the window start happens based on an event containing a certain value. Then, the window will progress for 15 seconds, collect all events that come in during the 15 seconds and close the window. I would like to aggregate all window events after. I've checked the Flink window functions and none seem to solve my use-case.
Copy code
outputStream = ewSubStream.keyBy(new KeySelector())
    .window(new SessionWindowAssigner(15000))
    .trigger(new SessionWindowTrigger())
    .aggregate(new SessionModelAggregator())
    .map(new SessionModelEvaluator());
I tried it the above way where each of the window, trigger and aggregate functions are custom. Doesn't seem to work. I also tried this way:
Copy code
outputStream = ewSubStream.keyBy(new VehicleKeySelector())
    .window(TumblingEventTimeWindows.of(Time.seconds(15))) // tried with .window(EventTimeSessionWindows.withGap(Time.seconds(15))) as well
    .trigger(new SessionWindowTrigger())
    .aggregate(new SessionModelAggregator())
    .map(new SessionModelEvaluator());
There is no exception I see but no logs are printed that I have in the trigger function. My trigger function looks like this:
Copy code
@Override
public TriggerResult onElement(Element element, long timestamp, TimeWindow window, TriggerContext ctx) throws Exception {
  MapString, Object data = element.getData();
  log.info("elementtrigger: {}", element);
  if (data.containsKey("key") &&
      data.get("my_record_key").toString().equals("active")) {
    log.info("firing: {}", element);
    return TriggerResult.FIRE;
  }
  return TriggerResult.CONTINUE;
}
Basically, I would like to trigger / start the window when the
my_record_key=active
and run the windowing for 15 seconds and stop this window session. Any ideas/thoughts are helpful! πŸ™‚
Hey all, bumping this up. anyone has thoughts on this? Not sure if I'm missing anything from Flink documentation.