How to maintain output order of events by execution initiation time.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to maintain output order of events by execution initiation time.

narasimha
Hi,

Below is my dataflow

DataStream stream ...

stream.process(new ProcessFunction())
.sink(...)


class ProcessFunction ...{
    MapState<Long, BusinessObject> time ...;

    processElement(...){
        //add Element to Mapstate by eventtime
        // register eventime+60 seconds 
    }

    // Reason for maintaining onTimer in the process function is to update the timer period.
    onTime(timestamp, ...) {
        // Iterate over the last n elements added to business objects at a given timestamp.
        // Emit to output if condition passes
    }
}


BusinessObject {
    List<BusinessEntities> entities;

    addEntity(BusinessEntities b);
}


This all looks good on code, but when processing elements with rate of 2k, the execution result emissions order is changing, i.e,
results of time T+t, are getting emitted first than results of T. 

Can someone give suggestions on how this can be handled, so that the results emissions order is guaranteed. 

Would popping them out and emitting using Sliding window of 1 sec would solve this?


Thanks,
Narasimha

--
A.Narasimha Swamy