Guruguha Marur Sreenivasa
04/15/2024, 4:26 PMoutputStream = 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:
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:
@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! πGuruguha Marur Sreenivasa
04/17/2024, 3:28 PM