[rules-users] Rules trace questions

Wolfgang Laun wolfgang.laun at gmail.com
Wed Nov 24 10:47:42 EST 2010


On 24 November 2010 15:10, Anais Martinez <amartinez at iti.upv.es> wrote:
>
> Thanks for your response.
>
> So, I have to change LogEvent.ACTIVATION_CREATED to
> LogEvent.AFTER_ACTIVATION_FIRE, right?

That's right. (Or BEFORE_...)


>
>>Triggering the writing of a log to disk by inserting a fact (Output) may
>>cause confusion since there's no guarantee that the firing according to
>>the new Output() will happen *next*. Other activations may result in
> firings
>>in between.
>
> You mean that if I write in the RHS, the event trace will contain
> activations of another traces?

Could be, yes. Not with this simple example, but, generally, yes. It
would depend on the salience used with other rules, and other factors.

Rule firing is indeterministic and its order is different from the order
activations are created.


>
> Is WorkingMemoryInMemoryLogger unstable too? I just have tested it by
> sending the
> result of getEvents from RHS to a java class (which controles the string). I
> have change the filter too. In the main method:
>
>
>  Message message = new Message();
>  message.setMessage("Message 1 hello");
>  message.setStatus(Message.HELLO);
>  ksession.insert(message);
>
>  Message message2 = new Message();
>  message2.setMessage("Message 2 goodbye");
>  message2.setStatus(Message.GOODBYE);
>  ksession.insert(message2);
>
>  ksession.fireAllRules();
>
> The result of getEvents() is:
>
> <object-stream>
>  <list>
>    <org.drools.audit.event.ActivationLogEvent>
>      <type>7</type>
>      <activationId>GoodBye [2]</activationId>
>      <rule>GoodBye</rule>
>      <declarations>myMessage=Message 2 goodbye(2)</declarations>
>    </org.drools.audit.event.ActivationLogEvent>

Rule GoodBye fires first, because you have inserted the fact that fires it
as the second one. A very low-level strategy (all other things being equal)
says "last in, first out".

>    <org.drools.audit.event.ActivationLogEvent>
>      <type>7</type>
>      <activationId>regla final [3]</activationId>
>      <rule>regla final</rule>
>      <declarations>s=Salida( text=Message 2 goodbye )(3)</declarations>
>    </org.drools.audit.event.ActivationLogEvent>

Again, LIFO, due to the insertion of Salida() in the consequence of GoodBye.


>    <org.drools.audit.event.ActivationLogEvent>
>      <type>7</type>
>      <activationId>Hello World [1]</activationId>
>      <rule>Hello World</rule>
>      <declarations>myMessage=Message 1 hello(1); m=Message 1
> hello(1)</declarations>
>    </org.drools.audit.event.ActivationLogEvent>

Due to the insertion of Message "Message 1 hello".


>    <org.drools.audit.event.ActivationLogEvent>
>      <type>7</type>
>      <activationId>GoodBye [1]</activationId>
>      <rule>GoodBye</rule>
>      <declarations>myMessage=Message 1 hello(1)</declarations>
>    </org.drools.audit.event.ActivationLogEvent>

Rule "Hello World" has changed the fact and this causes another
activation of rule GoodBye, which we see here.

Don't translate your names. We can read Spanish, even when we don't
know what it means. ¡Caramba! ;-)
-W


>  </list>
> </object-stream>
>
> Thank you again.
> --
> View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rules-trace-questions-tp1960008p1960828.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>




More information about the rules-users mailing list