Scenario:
I have a stream of events coming from the sensor. The Event could be of T-type or J-Type.
- T-type events have event occurred timestamp.
- J-type events have a start and end timestamp.
Based on the start and end timestamp of J-Type event, apply aggregation logic on all the T-type events that fall within the time range and write the result to a DB.
For this, I have created a custom trigger, which gets triggered when a J-Type event is received. In my custom ProcessWindowFunction, I am performing the aggregation logic and time check.
But, there could be a scenario, where T-type event doesn't fall in the time range of the current J-Type event. In that case, the T-type event should be pushed to the next window before purging the current window.
Thought of Solutions:
Push the unprocessed T-type events into the Kinesis stream (the source), in the custom window process function. (Worst case solution)
Instead of FIRE_AND_PURGE, use FIRE, to maintain the state throughout the runtime. Remove processed elements using the elements Iterator. ( Not recommended, to keep an infinite window)
Would like to know, if there is any way to directly push the un-processed events back to the input stream (without kinesis). (Re-queuing)
Or
Is there any way to maintain state in the keyBy Context, so that, we perform computation on these unprocessed data, (before or)along with the window elements.