wso2 - Query with Siddhi CEP using two times windows and 2 streams (continued) -


i keep trying make complex correlations siddhi, on occasion have 2 input streams, web client consult , notices sent clients visits, want generate alert if first stream each client repeated more once long second stream not has occurred under 2 windows , depends of status of events.

define stream consults (idclient string,dniclient string,codproduct string,codsubproduct string,chanel string,time string )  define stream comercialactions(idclient string, idaccioncomercial string,codproduct string,codsubproduct string,chanel string,time string,status string)  consults[codproduct=='fondos']#window.time(50 seconds) select idclient,codproduct, codsubproduct, chanel, time, count(idclient) visitcount group idclient insert consultsavg current-events  consultsavg[visitcount==1] select idclient, '' idaccioncomercial,codproduct, codsubproduct ,chanel, time, 'temp' status insert comercialactions all-events  comercialactions[status=='temp' or status == 'lanzada' ]#window.time(5 seconds) select idclient idclient, codproduct, codsubproduct, chanel, status, count(idclient) num_status group idclient insert acciones_generadas all-events  comercialactions[status=='temp' or status=='aceptada' or status =='rechazada'or status=='caduca']#window.time(3 seconds) select idclient idclient, codproduct, codsubproduct, chanel, status,  count(idclient) num_status group idclient insert acciones_realizadas all-events  consultsavg[visitcount>=2]#window.time(50 seconds) c join acciones_realizadas[num_status>=1]#window.time(5 seconds) ag on c.idclient == ag.idclient , c.codproduct==ag.codproduct select c.idclient,c.codproduct,c.codsubproduct,c.chanel, c.time, count(c.idclient) conteo insert posible_ac all-events  posible_ac#window.time(5 seconds) pac  join acciones_generadas[num_status>=1]#window.time(1 seconds) ar on pac.idclient == ar.idclient select pac.idclient,pac.codproduct,pac.codsubproduct,pac.chanel,pac.time,conteo, count(ar.idclient) conteo2  insert enviar_ac  enviar_ac[conteo==1 , conteo2==1] select idclient, codproduct,codsubproduct, chanel, time insert generar_accion_comercial 

what try use intermediate streams count number of website hits when greater or equal 2 , see if has made commercial action customer through various joins... think 've become complicated , not know if there simpler solution ??? , considering not have function siddhi not happened nor other join ( left join )

you can accomplish pattern. in case assume have wait 1 minute event second stream , if there's none, , more 1 event first, going emit output.

from consults#window.time(1 minute) select idclient, count(idclient) idcount, <select more attributes here> insert expiredconsultsstream expired-events;  expiredconsultsstream[idcount > 1] select * insert filteredconsultsstream;  firstevent = consults ->  nonoccurringevent = commercialactions[firstevent.idclient == idclient]  or triggerevent = filteredconsultsstream[firstevent.idclient == idclient] select firstevent.idclient id, triggerevent.idcount idcount, nonoccurringevent.idclient nid having( not (nid instanceof string)) insert alertstream; 

these draft queries, may require modifications them working. filteredconsultsstream contains consult events more 1 occurrence within last minute. in last query or of conditions as: nonoccurringevent = commercialactions[firstevent.idclient == idclient] or triggerevent = filteredconsultsstream[firstevent.idclient == idclient]

so query triggered 1 of above occurrences. but, need find whether condition triggered commercialactions. use 'having' clause , check whether id null (id null implies event null, non-occurrence). emit output.

you can find better description similar query here (that new 4.0.0 version btw , there small syntax changes)


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -