Hi All,
I have one requirement where I need to calculate total amount of transactions 
done by each each user in last 1 hour.Say Customer1 has done 2 transactions one 
at 11:00am and other one at 11:20 am.Customer2 has done 1 transaction one at 
10:00 am Customer3 has done 3 transactions one at 11:20 am,  11:40 am and 11:45 
am.
when ever customer does a transaction then we receive an event in source topic, 
we consume the data and need to calculate the total amount spent by Customer in 
last 1 hour.
if I have received customer1 new transaction event at 11:30 am then I need to 
calculate the sum of 3 events done by customer1 in last 1 hour (i.e 11:00 , 
11:20 and 11:30 am - all 3 events fall in last 1 hour window)Now say I receive 
Customer2 new transaction event at 11:30 am then for this customer I need to 
consider only one event 11:30 (ignoring the event at  10:00 am  as it does not 
fall in last 1 hr)Customer3 new transaction is done at 12:40 pm then for this 
Customer I need to calculate sum of ( 11:40 am , 11:45 am and 12:40pm) as all 3 
fall under last 1 hr.
Approach I am planning to try:Every event has the transaction time which I am 
using as event time to assign WatermarkStrategyKeyBy - 
customerIdSlidingEventTimeWindows of 1 hr then process all elements using 
ProcessWindowFunction

Kindly suggest the approach I need to follow to achieve the above scenario 
using Flink Java /Sql. I am using Flink 1.12.0.
Regards,Sunitha

Reply via email to