Hi,
in our project we're dealing with a stream of billing events. Each has
customerId and charge amount
We want to have a process that will trigger event (alarm) when sum of
charges for customer during last 4 hours exceeds certain threshold, say
- 10.
The triggered event should contain data from last billing event (the one
that triggered alarm)
One one hand we can implement it as custom state - we'd save charges (or
some precomputed aggregates) from last 4 hours and trigger event when
new one arrives.
OTOH we've been thinking if we can make it easier by using flink windows.
We tried to model our situation as sliding events (of length 4hours,
slide is 1h), have some precomputed aggregate and have a custom trigger
that fires on element when threshold is exceeded.
It kinda works, except for the fact that state is unnecesarily large,
custom trigger is a bit hacky and (worst of all) when event with charge
amount e.g. 20 arrives trigger fires in all slides and we have
duplicated events.
That's why we currently think about implementing it by custom state...
Do you have any other ideas/recommendations how can we handle such
requirement?
thanks,
maciek