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

Alexander Wolf mail at alexander-wolf.net
Mon Sep 9 07:43:08 EDT 2013


The question is more or less where to begin. 

1. If there is a Fact in working memory (e.g. "Person") and I invoke fireAllRules() twice, I would expect to have the following rule fire both times:

rule "alwaysFire"
when
	$room : Room( )
then
	System.out.println("there is a room");
end

I would also expect this rule to fire every time I invoke fireAllRules()

rule "alwaysFire2"
when
then
	System.out.println("always!");
end

Both rules fire only once (the first time) even though the Working Memory is the same. (The room still exists...). I expected the rule to fire each time fireAllRules() is invoked and for the number of Rooms e.g. with 4 rooms -> 4x output "there is a room".

2. It seems to be impossible to set the pseudo clock to a specific time. How can I test CRON timer rules?!



On 08.09.2013, at 18:51, Michael Anstis <michael.anstis at gmail.com> wrote:

> What did not happen as you expected?
> 
> The HTTP session to Knowledge session association seems reasonable; but I assume you are trying with a more simple configuration initially.
> 
> Sent on the move
> 
> On 8 Sep 2013 17:42, "amarok" <mail at alexander-wolf.net> wrote:
> 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.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130909/4b3ddd28/attachment-0001.html 


More information about the rules-users mailing list