[rules-users] Drools AgendaEventListener

Edson Tirelli ed.tirelli at gmail.com
Thu Nov 18 15:03:36 EST 2010


   The obvious answer is those callbacks happen when rules are
activated/cancelled/etc. If you are not seeing those callbacks, then
your rules are not being activated.

   I copy&pasted your code bellow into the default drools sample
project that is created when you create a new drools project in the
eclipse IDE plugin, and everything worked as expected, including the
MBean for session monitoring that you were asking about yesterday. So
I believe the problem is in your application code.

   Edson

2010/11/18 Agarwal, Beena <BAgarwal at ea.com>:
> Can anyone explain when the ActivationCreatedEvent,
> BeforeActivationFiredEvent,AfterActivationFiredEvent are actually triggered?
> I added a AgendaEventListener on a StatefulKnowledgeSession and never see
> the events being fired when I’m in the debugger.
> I’m basically trying to collect some session stats.
>
> Here’s a snippet –
>
> KnowledgeBaseConfiguration kbaseConf =
> KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
>                 kbaseConf.setOption(MBeansOption.ENABLED);
>                 commonKB =
> KnowledgeBaseFactory.newKnowledgeBase("kb-"+gameCode, kbaseConf);
>
> commonKB.addKnowledgePackages(kbuilder.getKnowledgePackages());
>
>                 StatefulKnowledgeSession session =
> commonKB.newStatefulKnowledgeSession();
>
>
>
>                 //session.addEventListener(bean.getAgendaStats());
>
>                 session.addEventListener(new DefaultAgendaEventListener() {
>                         public void
> activationCancelled(ActivationCancelledEvent event) {
>                                 System.out.println("activation cancelled");
>                         }
>
>                             public void
> activationCreated(ActivationCreatedEvent event) {
>                                  System.out.println("activation created");
>                             }
>
>                             public void
> afterActivationFired(AfterActivationFiredEvent event) {
>                                  System.out.println("after activation
> fired");
>                             }
>
>
>                             public void
> beforeActivationFired(BeforeActivationFiredEvent event) {
>                                  System.out.println("before activation
> fired");
>                                  }
>                             });
>
> .. add facts..
> Session.fireAllRules();
>
>
> I never see the printlns or the breakpoints in the DefaultAgendaListener –
> are these supposed to be triggered when the rules are fired?
>
>
>
>
>



-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com




More information about the rules-users mailing list