[rules-users] Working Memory and agenda-group

Mike Key mikey at zenbitz.com
Thu Dec 29 18:24:23 EST 2011


I guess that is exactly my confusion :)  Why would it be that doing the
exact same thing, one inserting into working memory from a function and the
other simply doing it within the RHS of the rule cause downstream rules not
to fire in the function call case?  The rules are both in the same
agenda-group, both the function example and the insert from the RHS of the
rule example are simply inserting a new fact into working memory.

It makes it seem like the function call is somehow inserting into a
*different* working memory, which I'm sure is not the case, but the
downstream rule does not fire none-the-less.

Thanks for any clarity.


On Thu, Dec 29, 2011 at 3:59 PM, Mauricio Salatino <salaboy at gmail.com>wrote:

> Agenda-groups segment the agenda and not the working memory :)
> Probably that is part of your confusion.
>
>
> 2011/12/29 Mike Key <mikey at zenbitz.com>:
> > I am a fairly new Drools user and am trying to understand how working
> memory
> > is segmented when using agenda groups.  I have an agenda-group that has
> > focus set immediately from the session as follows with a few objects
> being
> > inserted:
> >
> > ksession.insert(objectA);
> > ksession.insert(objectB);
> > ksession.getAgenda().getAgendaGroup("Foo").setFocus();
> >
> > I have 2 rules simplified down to illustrate my confusion.  The first
> rule
> > simply sets some default values evaluated in the second rule if objectA
> > exists.  In the example that works I set the defaults in the RHS
> explicitly.
> >  However I want to use these defaults from different agenda-groups, so
> when
> > I put them in a function, the second rule never fires, the activation is
> > created for the first rule but never the second.  Can someone tell me why
> > the use of a function seems to alter the truth of the rule?
> >
> > THIS WORKS:
> >
> > declare SomeDefault
> >   minValueA : Integer
> >   minValueB : Double
> >   maxValueB : Double
> > end
> >
> > rule "Check Object A and Set Default"
> >   agenda-group "Foo"
> >   salience 100
> >   when
> >     $a : ObjectA()
> >   then
> >     default = new SomeDefault()
> >     default.minValueA = 100
> >     default.minValueB = 20.0
> >     default.maxValueB = 20000.0
> >     insert(default)
> > end
> >
> > rule "Use the defaults"
> >   agenda-group "Foo"
> >   salience 100
> >   when
> >     $default : SomeDefault()
> >   then
> >     System.out.println("Default minA=" + $default.minValueA)
> > end
> >
> > THIS DOES NOT WORK:
> >
> > declare SomeDefault
> >   minValueA : Integer
> >   minValueB : Double
> >   maxValueB : Double
> > end
> >
> > rule "Check Object A and Set Default"
> >   agenda-group "Foo"
> >   salience 100
> >   when
> >     $a : ObjectA()
> >   then
> >     insertDefault(drools.getWorkingMemory())
> > end
> >
> > rule "Use the defaults"
> >   agenda-group "Foo"
> >   salience 90
> >   when
> >     $default : SomeDefault()
> >   then
> >     System.out.println("Default minA=" + $default.minValueA)
> > end
> >
> > function void insertDefault(WorkingMemory workingMemory) {
> >   SomeDefault default = new SomeDefault();
> >   default.setMinValueA(100);
> >   default.setMinValueB(20.0);
> >   default.setMaxValueB(20000.0);
> >   workingMemory.insert(default);
> > }
> >
> > In the latter (non-working) example the first rule activates and then
> drools
> > returns, it never even attempts to try to fire the second rule.  However
> in
> > the working example BOTH rules fire as I would expect.  I am guessing
> this
> > is a simple misunderstanding on my part.  Any assistance in understanding
> > why this nuance doesn't seem to work would be greatly appreciated.
> >
> > Thanks.
> >
> > MiKey
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
>
>
>
> --
>  - CTO @ http://www.plugtree.com
>  - MyJourney @ http://salaboy.wordpress.com
>  - Co-Founder @ http://www.jugargentina.org
>  - Co-Founder @ http://www.jbug.com.ar
>
>  - Salatino "Salaboy" Mauricio -
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20111229/ac573dea/attachment.html 


More information about the rules-users mailing list