[rules-users] Logging Rules Fired on a Fact -- Best Practices

BenjaminWolfe benjamin.e.wolfe at gmail.com
Tue Aug 7 19:10:21 EDT 2012


Is there a way to log what rules have interacted with a fact -- and keep the
logging with the fact?  What are the best practices for that?

For example, facts are unmarshalled from an XML stream:

<important_fact>
    <foo>bar</foo>
</important_fact>

Then my rules interact with it:

rule "my rule"
    no-loop true
    dialect "mvel"
    when
        i : important_fact()
    then
        i.setFoo("fee");
end

rule "my second rule"
    no-loop true
    dialect "mvel"
    when
        i : important_fact( foo = "fee" )
    then
        i.setFoo(i.getFoo + "foo");
end

Then I'm thinking I'd like the marshalled output to be something like this
(except maybe with unique rule IDs instead of just names):

<important_fact>
    <foo>feefoo</foo>
    <rule_history>
        <rule>my rule</rule>
        <rule>my second rule</rule>
    </rule_history>
</important_fact>

But I'm pretty new at this.  Is that ever done?  If so, what are the best
practices?  If not, maybe there's a good reason, so why not?



--
View this message in context: http://drools.46999.n3.nabble.com/Logging-Rules-Fired-on-a-Fact-Best-Practices-tp4019054.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list