wso2wso2-cep

WSO2 CEP Stream Count function restart


I have the following query:

from stream1
select count() as item insert into newStream;

Is it possible to restart the count() function of a stream?

If not, how can I circumvent this? If possible.


Solution

  • If you use count() or any other aggregate function without a window, there's no way to reset the events that get accumulated within that aggregator. For example if you use a window like below, it will reset the counter after receiving 10 events.

    from stream1#window.lengthBatch(10)
    select count() as item insert into newStream;
    

    However, If you need to reset the counter by sending an parameter to it, (i.e count(bool reset)) you may have to write your own custom aggregate function as described in the following documentation.