[rules-users] A Drools CEP Scenario - did I get it right?

amarok mail at alexander-wolf.net
Sun Sep 8 12:41:26 EDT 2013


I got the following scenario: 
- I need a Web Service that reasons over received sensor events (1000+ per
day and client) in realtime and send messages if certain patterns occur. 
- The web service has many clients (100-1000) but their events / facts do
not interfere (each client has his own state and events that change his
state).
- Each client also has his own rules (10-100) (but they are parameterized
generic rules - I thought maybe I could use rule templates or DSL to let
clients individualize their rules).  
- Some rules are time dependant (e.g. if event (type=x) does not occour at
least within half an hour after 8:00 a.m. (where 8 o'clock is a rule
parameter) -> send a message), others are accumulative (e.g. if number of
events within 5h is > 3).


I'd like to use drools CEP for this. I already read some documentation and
tutorials but my first examples do not really work as I expected. Now I fear
to have some general misconception about Drools/CEP. If someone could have a
look over my ideas, I'd be very glad!


How I would do it:
-> Every client would have his own KnowledgeBase with his (individualized)
rules. Rules would be stored in guvnor or on a mysql database as plain text.
-> Every client would have his own KnowledgeBase / StatefullKnowledgeSession
on the service, that knows about recent sensor events and some facts about
the client. Events automatically are disposed of once they are not relevant
anymore.
-> A static hashmap will hold references to the session for each client. 
(clientID -> KnowledgeSession)
-> Sessions are created when a new client joins the system, but are normally
not disposed unless the client completely leaves the system.
-> When a new Event is received (HTTP PUT), the session corresponding to the
client would be retrieved from the HashMap and the new event would be
inserted via an event stream. Then (for every new event)
session.fireAllRules() would be called on the clients KnowledgeSession.

-> The Knowledge Base would run in STREAM mode to be able to reason over
time windows and automatically expire (=delete?!) events. This would keep
memory usage in within bounds(?)
-> pseudo clock allows me to write tests or simulate the system with records
of old events. (Is it possible to test timer, cron and sliding-window rules
with pseudo clock? Can I explicitly set the time of the pseudo clock?)

I appreciate your help!
 
 









--
View this message in context: http://drools.46999.n3.nabble.com/A-Drools-CEP-Scenario-did-I-get-it-right-tp4025863.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list