[rules-users] How to empty the Working memory

Wolfgang Laun wolfgang.laun at gmail.com
Mon Mar 12 05:02:57 EDT 2012


Perhaps you should use a rule to retract anything except the "initial fact":

rule "Clear"
salience -1000000
when
    $f: Object( eval( ! $f.getClass().equals(
org.drools.reteoo.InitialFactImpl.class) ) )
then
    retract( $f );
end

Alternatively, use the type of an inserted fact, instead of Object and
omit the eval.

-W



On 12/03/2012, Spade87 <johan.spade at gmail.com> wrote:
> Hi,
>
> I'm using Drools as a part of a Mule ESB solution and I'm having some
> problems. Each time i send a message to Drools from the ESB it's content
> get's asserted as a new fact in the working memory and then there it stays.
> I would like to only fire the rules on the content of the last message. Is
> there some way to get a fresh working memory for each time drools is called.
>
> I found this post
> http://drools.46999.n3.nabble.com/How-to-make-the-working-memory-quot-clean-quot-td3790730.html
>
> but i didn't understand how or if it was possible to do only using drl
> files. I've tried passing the drools and kcontext variables to static helper
> methods and assign a new session each time but then the application just
> freezes up.
>
> Regards
> //Johan
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/How-to-empty-the-Working-memory-tp3818693p3818693.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
>



More information about the rules-users mailing list