<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>The question is more or less where to begin.&nbsp;</div><div><br></div><div>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:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(0, 143, 0); "><span style="color: #a91500">rule</span><span style="color: #000000"> </span>"alwaysFire"</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(169, 21, 0); ">when</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>$room : Room( )</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(169, 21, 0); ">then</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>System.out.println(<span style="color: #008f00">"there is a room"</span>);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(169, 21, 0); ">end</div></div><div><br></div><div>I would also expect this rule to fire every time I invoke fireAllRules()</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(0, 143, 0); "><span style="color: rgb(169, 21, 0); ">rule</span><span style="color: rgb(0, 0, 0); ">&nbsp;</span>"alwaysFire2"</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(169, 21, 0); ">when</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(169, 21, 0); ">then</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>System.out.println(<span style="color: rgb(0, 143, 0); ">"always!"</span>);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(169, 21, 0); ">end</div></div><div><br></div><div>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 -&gt; 4x output "there is a room".</div><div><br></div><div>2. It seems to be impossible to set the pseudo clock to a specific time. How can I test CRON timer rules?!</div><div><br></div><div><br></div><br><div><div>On 08.09.2013, at 18:51, Michael Anstis &lt;<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p dir="ltr">What did not happen as you expected? </p><p dir="ltr">The HTTP session to Knowledge session association seems reasonable; but I assume you are trying with a more simple configuration initially.</p><p dir="ltr">Sent on the move</p>
<div class="gmail_quote">On 8 Sep 2013 17:42, "amarok" &lt;<a href="mailto:mail@alexander-wolf.net">mail@alexander-wolf.net</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I got the following scenario:<br>
- I need a Web Service that reasons over received sensor events (1000+ per<br>
day and client) in realtime and send messages if certain patterns occur.<br>
- The web service has many clients (100-1000) but their events / facts do<br>
not interfere (each client has his own state and events that change his<br>
state).<br>
- Each client also has his own rules (10-100) (but they are parameterized<br>
generic rules - I thought maybe I could use rule templates or DSL to let<br>
clients individualize their rules).<br>
- Some rules are time dependant (e.g. if event (type=x) does not occour at<br>
least within half an hour after 8:00 a.m. (where 8 o'clock is a rule<br>
parameter) -&gt; send a message), others are accumulative (e.g. if number of<br>
events within 5h is &gt; 3).<br>
<br>
<br>
I'd like to use drools CEP for this. I already read some documentation and<br>
tutorials but my first examples do not really work as I expected. Now I fear<br>
to have some general misconception about Drools/CEP. If someone could have a<br>
look over my ideas, I'd be very glad!<br>
<br>
<br>
How I would do it:<br>
-&gt; Every client would have his own KnowledgeBase with his (individualized)<br>
rules. Rules would be stored in guvnor or on a mysql database as plain text.<br>
-&gt; Every client would have his own KnowledgeBase / StatefullKnowledgeSession<br>
on the service, that knows about recent sensor events and some facts about<br>
the client. Events automatically are disposed of once they are not relevant<br>
anymore.<br>
-&gt; A static hashmap will hold references to the session for each client.<br>
(clientID -&gt; KnowledgeSession)<br>
-&gt; Sessions are created when a new client joins the system, but are normally<br>
not disposed unless the client completely leaves the system.<br>
-&gt; When a new Event is received (HTTP PUT), the session corresponding to the<br>
client would be retrieved from the HashMap and the new event would be<br>
inserted via an event stream. Then (for every new event)<br>
session.fireAllRules() would be called on the clients KnowledgeSession.<br>
<br>
-&gt; The Knowledge Base would run in STREAM mode to be able to reason over<br>
time windows and automatically expire (=delete?!) events. This would keep<br>
memory usage in within bounds(?)<br>
-&gt; pseudo clock allows me to write tests or simulate the system with records<br>
of old events. (Is it possible to test timer, cron and sliding-window rules<br>
with pseudo clock? Can I explicitly set the time of the pseudo clock?)<br>
<br>
I appreciate your help!<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/A-Drools-CEP-Scenario-did-I-get-it-right-tp4025863.html" target="_blank">http://drools.46999.n3.nabble.com/A-Drools-CEP-Scenario-did-I-get-it-right-tp4025863.html</a><br>

Sent from the Drools: User forum mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div>
_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/rules-users</blockquote></div><br></body></html>