Siddhi complex event processing using logical AND

211 Views Asked by At

I am using SiddhiQL for complex event processing. My use case is to check whether two events of a particular type with certain filters occur within 15 mins. Like for example -

If event1[filter 1] and event2[filter 2] within 15 mins
Insert into output stream 

In my case any of the two events can occur first and i need to check whether after receiving the first event, do i receive the second event within 15 mins.

Is this possible in SiddhiQL?

EDIT #1 - I have defined my streams and events below (The below code does not work)

define stream RegulatorStream(deviceID long, roomNo int, tempSet double);

@sink(type = 'log', prefix = "LOGGER")
define stream outputStream (roomNo int,rooomNo int);

from e1 = RegulatorStream[roomNo==23] and e2 = RegulatorStream[e1.deviceID == deviceID AND roomNo ==24] within 5 minutes 
select e2.roomNo,123 as rooomNo
insert into outputStream;

In above case, I need to alert when I receive events in my RegulatorStream having roomNo = 23 AND roomNo = 24 within 5 mins in any order with same deviceID.

How can this be achieved in SiddhiQL?

1

There are 1 best solutions below

5
Chiran Fernando On

Yes this can achieved with Siddhi Patterns. Please refer the documentation on Siddhi Patterns in https://siddhi.io/en/v5.1/docs/query-guide/#pattern and examples in https://siddhi.io/en/v5.1/docs/examples/logical-pattern/.

You can use OR operation within the pattern to bypass the event occurrence order.