yes.. you are missing that if you don't put the agenda group in the stack it will never be used.
Like Bali said "Whenever the focus is set
to a different group, Drools adds this group to a stack". If you don't set the focus to another agenda group, the only one in the Stack is MAIN.

On Thu, Jan 21, 2010 at 1:11 PM, Pritam <infinity2heaven@gmail.com> wrote:

I'm not quite sure howDrools processes and partitions Agenda based on
agenda-groups as the documentation conflicts with a real example. As per the
documentation in Drools site and Michael Bali's book, page 102

"Drools maintains a stack of Agenda groups. Whenever the focus is set to
true, the active agenda-group is automatically changed to rule's agenda
group. Drools maintains a stack of agenda groups. Whenever the focus is set
to a different group, Drools adds this group to a stack. When there are no
rules to fire from the agenda group, Drools pops from the stack and sets the
agenda group to the next one."

However, when I run a simple example with two rules having agenda groups
set, none of the rules are fired unless the agenda-group is explicitly set
to runtime. Based on the above example, I would expect Drools Agenda to run
all rules under "MAIN" and since there are none, it should pop it out and
point to the next available group and so on.

Am I missing something here?


package com.sample

import com.sample.DroolsTest.Message;

rule "Hello World"
agenda-group "group1" # comment this and rule fires
       when
               m : Message( status == Message.HELLO, myMessage : message )
       then
               System.out.println( myMessage );
               m.setMessage( "Goodbye cruel world" );
               m.setStatus( Message.GOODBYE );
               update( m );
end

rule "GoodBye"
agenda-group "group 2" # comment this and rule fires
       when
               Message( status == Message.GOODBYE, myMessage : message )
       then
               System.out.println( myMessage );
end


DroolsTest:-

KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
ksession.insert(message);
// ksession.getAgenda().getAgendaGroup("group1").setFocus();   // enable
this only group1 is fired, not // group2
ksession.fireAllRules();
--
View this message in context: http://n3.nabble.com/Understanding-agenda-group-doesn-t-work-as-documented-in-book-or-docs-tp133386p133386.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -