Siddhi dynamic business rules

149 views
Skip to first unread message

Kristine Gevorgyan

unread,
Sep 1, 2020, 4:06:09 PM9/1/20
to siddhi-dev
Hi,
We're looking for stream data processor and considering Siddhi as one of candidates.
We have 1 critical requirement which we're not able to find a way to cover with Siddhi.
Can you please help me find out is it possible to have dynamic business rules with Siddhi?

We have IoT devices collecting and sending sensor data to Siddhi.
We need to process that data according to rules setup by user.

e.g. rule can be
for sensorId=1235 if sensorValue > 500 , send notification to email "some...@gmail.com"

For each sensor we need to be able to dynamically attach and detach rules at any point of time. 

RuleEngine_IO_Channels-Copy of IO_Channels.png

Is there way to achieve this with Siddhi?

charukaka...@gmail.com

unread,
Sep 2, 2020, 12:56:59 AM9/2/20
to siddhi-dev
Hi,

Yes, This can be achieved using the business rules feature included in Streaming Integrator Tooling. please refer to[1]

Kristine Gevorgyan

unread,
Sep 7, 2020, 11:16:12 AM9/7/20
to siddhi-dev
Hi and thanks for reply.
But using  Streaming Integrator Tooling  will not work for us, we have our own management app and this is what our users shoulduse for setting up rules, we cannot redirect them to another app, but need a way to send rules to Siddhi in background.

Senthuran Ambalavanar

unread,
Sep 7, 2020, 12:29:11 PM9/7/20
to Kristine Gevorgyan, siddhi-dev
Hi,

Will storing the rules in a database table work for you? If yes, we can try the following approach.

Have a table in your database called RULES(sensorId, threshold, email), to store the rules (we can add/remove as required).
In the Siddhi app, we can refer to this from a defined Table [1].

When it comes to creating a rule, we can use a Siddhi On-demand Query [2] to send events to the RULES table, but from external API calls.
These API calls can be made using your management app.
An example CURL command for inserting a rule would be like:
curl -X POST https://localhost:9443/query -H "content-type: application/json" -u "admin:admin" -d '{"appName" : "SampleApp", "query" : "select \"S01\" as sensorId, 40 as threshold, \"a...@email.com\" as email insert into RULES;" }' -k
Similarly, we can delete a rule from the RULES table (Please refer [3] for examples).

For checking against a rule, we receive sensor data from a stream, perform a join with the RULES table - on sensorId, 
compare against the threshold, and send alert to the appropriate email.


--
Siddhi homepage: http://siddhi.io/
Siddhi Github repo: https://github.com/siddhi-io/siddhi
 
You received this message because you are subscribed to the Google Groups "Siddhi-dev" group.
To post to this group, send email to siddh...@googlegroups.com
To unsubscribe from this group, send email to siddhi-dev+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/siddhi-dev?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "siddhi-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to siddhi-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/siddhi-dev/abd63335-086b-4add-875b-73b04c802fa3n%40googlegroups.com.


--
Senthuran Ambalavanar | Software Engineer | WSO2 Inc.

Kristine Gevorgyan

unread,
Sep 15, 2020, 4:11:50 PM9/15/20
to Senthuran Ambalavanar, siddhi-dev
HI Senthuran,
Yes, storing rules in the database will work.
But it looks like joining has limitation requiring both streams to have an associated window.

Not sure how we can overcome it.



Best,
Kristine  

Senthuran Ambalavanar

unread,
Sep 15, 2020, 4:29:54 PM9/15/20
to Kristine Gevorgyan, siddhi-dev
Hi Kristine,

If we are going to store the rules in a database table, the join will be between a stream and a table. (Stream: Incoming sensor data, Table: rules)
Therefore, windows on either side are not required.

In the example you pointed out (https://siddhi.io/en/v4.x/docs/query-guide/#join-stream), windows are required because the join is between a stream and another stream.

Regards,
Senthuran.

Reply all
Reply to author
Forward
0 new messages