Hi all:<br><br>I have a very basic doubt about Drools Fusion.<br><br>I have two simple Java classes:<br><br>EventA {<br> String id;<br> Date timestamp;<br> Long duration;<br>}<br><br>EventB {<br> String id;<br>
Date timestamp;<br> Long duration;<br>}<br><br>I have a DRL file, where I declare this two classes as Events:<br><br>declare EventA<br> @role(event)<br> @timestamp(timestamp)<br> @duration(duration)<br>end<br>
<br>declare EventB<br> @role(event)<br> @timestamp(timestamp)<br> @duration(duration)<br>end<br><br>I have a simple rule:<br><br>rule "Basic Rule"<br>dialect 'mvel'<br>when<br> $eventA: EventA($aId: id) from entry-point "time stream"<br>
then<br> System.out.println("Event A " + $aId + " at " + $eventA.timestamp);<br>end<br><br>Finally, I have a test that starts a StatefulKnowledgeSession in STREAM mode, register an eventLister in the session in order to fire the rules when an event arrives:<br>
<br>ksession.addEventListener(new DefaultAgendaEventListener() {<br> @Override<br> public void activationCreated(ActivationCreatedEvent event) {<br> ((StatefulKnowledgeSession) event.getKnowledgeRuntime()).fireAllRules();<br>
}<br>});<br><br>And then the test insert in the "time stream" entry-point an instance of EventA with duration of 10 miliseconds, as follows:<br><br>EventA eventA = new EventA(); <br>eventA.setId("123");<br>
eventA.setTimestamp(new Date());<br>eventA.setDuration(10L);<br>ksession.getWorkingMemoryEntryPoint("time stream").insert(event);<br><br>At the end of the test, I have an sleep of 2 seconds just in case.<br><br>
I don't understand why the "Basic Rule" never fires.<br><br>But if I add another condition to the same rule, something like this:<br><br>rule "Basic Rule"<br>dialect 'mvel'<br>when<br> $eventA: EventA($aId: id) from entry-point "time stream"<br>
not EventB($aId == id, this after [0s,5s] $eventA) from entry-point "time stream"<br>then<br> System.out.println("Event A " + $aId + " at " + $eventA.timestamp);<br>end<br><br>The rules fires and I see this message in console:<br>
<br>Event A 123 at Fri Dec 07 09:48:59 ART 2012<br><br>I don't understand why the first rule, that is more open, don't fire, and the second rule, that is more restrictive, fires without problems.<br><br>Thank you very much!<br>
<br>Greetings,<br>Adrian.<br clear="all"><br>-- <br><span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(0,84,128)"><b><span style="color:rgb(0,0,0);font-weight:normal;font-size:13px"><font><span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(0,84,128)"><b>Epidata Consulting | Deploying Ideas</b></span><br>
</font><div><font><span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(149,151,154)">Ing. Adrián M. Paredes | Arquitecto Desarrollador<br></span></font></div>
<div><span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(149,151,154)"><a href="mailto:adrianp@epidataconsulting.com" target="_blank">adrianp@epidataconsulting.com</a> | Cel: (54911) 3297 1713<br>
</span></div><div>
<div><font><span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(149,151,154)">----------------------------------------------------------------------------------------------------------------------------</span></font></div>
<div><font><span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(0,84,128)">Argentina: </span></font><span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(149,151,154)">Maipú 521 Piso 1 Of. A | Buenos Aires | Of: (5411) 5031 0060</span></div>
<div><font><span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(0,84,128)">Chile:</span> </font><span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(149,151,154)">Apoquindo 3600 Piso 7 y 9 | Las Condes - Santiago | Of: (+56) 2 495 8450</span></div>
<div><font><span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(149,151,154)">---------------------------------------------------------------------------------------------------------------------------</span></font></div>
<div><span style="font-size:12px;color:rgb(0,84,128)"><b><span style="color:rgb(0,0,0);font-weight:normal;font-size:13px"><div style="display:inline!important"><font><span style="color:rgb(149,151,154);font-family:arial,sans-serif;font-size:12px;border-collapse:collapse"><span style="color:rgb(0,84,128)"><b><span style="color:rgb(0,0,0);font-weight:normal;font-size:13px"><div style="display:inline!important">
<span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(149,151,154)"><a href="http://www.epidataconsulting.com/" target="_blank">www.epidataconsulting.com</a></span></div></span></b></span></span></font></div>
</span></b></span></div><div><span style="font-size:12px;color:rgb(0,84,128)"><b><span style="color:rgb(0,0,0);font-weight:normal;font-size:13px"><div style="display:inline!important"><font><span style="font-family:arial,sans-serif;font-size:12px;color:rgb(0,84,128)"><b><span style="color:rgb(0,0,0);font-weight:normal;font-size:13px"><div style="display:inline!important">
<font><span style="font-family:arial,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(149,151,154)"><a href="http://bit.ly/epidatalinkedin" target="_blank">Linkedin</a> | <a href="http://www.facebook.com/epidata.consulting" target="_blank">Facebook</a> | <a href="http://twitter.com/epidata" target="_blank">Twitter</a></span></font></div>
</span></b></span></font></div></span></b></span></div></div></span></b></span><br>