Here's a working example of using AgendaEventListener...

http://article.gmane.org/gmane.comp.java.drools.user/22375

Your example has the line attaching the AgendaEventListener to the session
commented out. This wouldn't help ;-)

Cheers,

Mike

2010/11/18 Agarwal, Beena <[email protected]>

>  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?
>
>
>
>
>
>
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to