Search code examples
wso2complex-event-processingwso2-cep

How to clear a CEP window


I wanted to block the same event(which has same title) entering twice to inOrg stream. So I used a "first unique" window. But at some point this will give an out of memory error. I want to clean the first unique window if it contains more than 1000 events. How can I do this?

This is the execution plan.

@Plan:name('ExecutionPlan')

@Import('instream:1.0.0')
define stream inOrg (meta_title string, meta_link string,     meta_description string, meta_item string);

@Export('outstream:1.0.0')
define stream out (meta_id int, meta_key string, meta_title string, meta_link string);

@From(eventtable='rdbms', datasource.name='EX_DB', table.name='table')
define table EventTypeTable (meta_id int, meta_key string);

from inOrg#window.firstUnique(meta_title)
select meta_title, meta_link, meta_description, meta_item
insert into in;

from in join EventTypeTable
select meta_id, meta_key, meta_title, meta_link , meta_description, meta_item
insert into StreamTemp;

from StreamTemp [(regex:find(str:lower(meta_key),str:lower(meta_title)) or regex:find(str:lower(meta_key),str:lower(meta_description))) ]
            select meta_id, meta_key, meta_title, meta_link
            insert into out;

Solution

  • Ramindu,

    Unfortunately there is no direct configuration like that for FirstUniqueQindow.

    This is happening because you send large number of uniques which you can't keep in memory. If the number of uniques does not grow infinitely, one easy option you can try is to increase JVM memory. For that open CEP_HOME/bin/wso2server.sh and edit JVM memory arguments accordingly.

    Ex: -Xms2048m -Xmx4096m -XX:MaxPermSize=1024m \

    But if you still want to clear unique window, which means you need to keep only latest 1000 unique events I am afraid there is no direct way. You will need to improve current implementation[1] to support that. Such a feature is mice to have and mostly welcome!!If you are willing to contribute send a mail to [email protected] and we can continue the discussion there.

    [1] https://github.com/wso2/siddhi/blob/master/modules/siddhi-core/src/main/java/org/wso2/siddhi/core/query/processor/stream/window/FirstUniqueWindowProcessor.java