Hi Jay, In that case, you can either remove events from the table which are older than 24hrs, or you can include a condition to the join query to ignore events that are older than 24hrs. Please refer to the sample below;
@Plan:name('TestExecutionPlan') > define stream publisher (pid string, time string); > define stream subscriber (pid string, sid string, time string); > define table publisherTable (pid string, time string, timestamp long); > define trigger purgeTrigger at '0 0 0 ? * *'; > -- Purge records older than 24 hours > > > *from purgeTrigger delete publisherTable on (triggered_time - > publisherTable.timestamp) >= 1000 * 60 * 60 * 24; * > from publisher > select pid, time, time:timestampInMilliseconds() as timestamp > insert into publisherTable; > -- Double check the time range > from subscriber as s join publisherTable as p > on p.pid == s.pid *AND ((time:timestampInMilliseconds() - p.timestamp) < > 1000 * 60 * 60 * 24)* > select p.pid, s.sid, s.time > insert into AlertStream; Regards, Grainier. On Fri, Sep 15, 2017 at 2:21 PM, Jayesh Senjaliya <jhsonl...@gmail.com> wrote: > Hi Grainier, > > even table approach make sense, but is there a way to limit the event > table to keep the events for let say 24 hour or so and then discard it ? > > Thanks for looking into this. > Jay > > > > > On Thu, Sep 14, 2017 at 11:51 PM, Grainier Perera <grain...@wso2.com> > wrote: > >> Hi Jay, >> >> In your pattern, when a match found, it will discard that event (e1 in >> your scenario), so it won't get compared with other events. However, if you >> need to hold that event and match it with more than a single event, then >> you can use an event table as shown below. >> >> @Plan:name('TestExecutionPlan') >>> define stream publisher (pid string, time string); >>> define stream subscriber (pid string, sid string, time string); >>> define table publisherTable (pid string, time string); >> >> >>> from publisher >>> insert into publisherTable; >> >> >> >> -- Option 1 >> >> from subscriber[publisherTable.pid == pid in publisherTable] >>> select pid, time >>> insert into AlertStream1; >> >> >> >> -- Option 2 >>> from subscriber as s join publisherTable as p >>> on p.pid == s.pid >>> select p.pid, s.sid, s.time >>> insert into AlertStream2; >> >> >> Regards, >> Grainier. >> >> On Fri, Sep 15, 2017 at 11:41 AM, Jayesh Senjaliya <jhsonl...@gmail.com> >> wrote: >> >>> Hello WSO2 community. >>> >>> I am trying to implement a siddhi query where 1 event in publisher can >>> have multiple event in subscriber. this fits well in pattern query but it >>> looks like it outputs as soon as 1 event is matched and there is no way to >>> window or tell the count. >>> >>> here is the execution plan i have came up with that should have matches >>> all mapping but its not working that way, it only outputs 1 event, the >>> first one that matches. >>> >>> can someone please look at this and help me figure out why it is not >>> working? or what would be right way to get this? >>> >>> Thanks >>> Jay >>> >>> >>> Execution Plan: >>> >>> @Plan:name('TestExecutionPlan') >>> define stream publisher (pid string, time string); >>> define stream subscriber (pid string, sid string, time string); >>> >>> @info(name = 'query2') >>> from every( e1=publisher ) -> e2=subscriber[ e2.pid == e1.pid ] >>> select e1.pid, e2.sid, e2.time >>> insert into AlertStream; >>> >>> >>> here is the sample events if you want to try on siddhi-try-it tool >>> >>> publisher=[1,2017-08-15 01:08:30.253] >>> publisher=[2,2017-08-15 02:08:30.253] >>> publisher=[3,2017-08-15 03:08:30.253] >>> >>> subscriber=[1, 12,2017-08-15 21:08:30.253] >>> subscriber=[1, 13,2017-08-15 21:10:30.253] >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> Dev mailing list >>> Dev@wso2.org >>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>> >>> >> >> >> -- >> Grainier Perera >> Senior Software Engineer >> Mobile : +94716122384 <+94%2071%20612%202384> >> WSO2 Inc. | http://wso2.com >> lean.enterprise.middleware >> > > -- Grainier Perera Senior Software Engineer Mobile : +94716122384 WSO2 Inc. | http://wso2.com lean.enterprise.middleware
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev