1 Reply Latest reply on Nov 26, 2011 11:50 PM by tsurdilovic

    Invocation of rule task in JBPM - Using JPA and within Web App

    ashpcs

      Hi All,

       

       

      I am trying to use ruletask in JBPM  using JPA  under web application.

       

      I would like to fire rule at proper condition  and believe that, use of fireUntilHalt within thread (and in web application) is not a good idea.

       

      I have see usage of org.drools.event.AgendaEventListener  by adding to session.  For JPA this can not be added.

       

       

      What is the best way to properly  fire the rule  using JAP and under web application? 

       

       

      Please let me know if I need to provide more details.

       

      Regards,

      Ashish

        • 1. Re: Invocation of rule task in JBPM - Using JPA and within Web App
          tsurdilovic

          Not sure why you say you cannot use AgendaEventListener? Can you elaborate?

          Here is one example (you have to do a little bit of casting...)

           

           

          final org.drools.event.AgendaEventListener agendaEventListener = new org.drools.event.AgendaEventListener() {

                          public void activationCreated(ActivationCreatedEvent event,

                                  WorkingMemory workingMemory){

                          }

                          public void activationCancelled(ActivationCancelledEvent event,

                                    WorkingMemory workingMemory){

                          }

                          public void beforeActivationFired(BeforeActivationFiredEvent event,

                                      WorkingMemory workingMemory) {

                          }

                          public void afterActivationFired(AfterActivationFiredEvent event,

                                     WorkingMemory workingMemory) {

                          }

                          public void agendaGroupPopped(AgendaGroupPoppedEvent event,

                                  WorkingMemory workingMemory) {

                          }

           

                          public void agendaGroupPushed(AgendaGroupPushedEvent event,

                                  WorkingMemory workingMemory) {

                          }

                          public void beforeRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event,

                                             WorkingMemory workingMemory) {

                          }

                          public void afterRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event,

                                  WorkingMemory workingMemory) {

                              workingMemory.fireAllRules();

                          }

                          public void beforeRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event,

                                               WorkingMemory workingMemory) {

                          }

                          public void afterRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event,

                                              WorkingMemory workingMemory) {

                          }

                      };

                      ((StatefulKnowledgeSessionImpl)  ((KnowledgeCommandContext) ((CommandBasedStatefulKnowledgeSession) ksession)

                              .getCommandService().getContext()).getStatefulKnowledgesession() )

                              .session.addEventListener(agendaEventListener);

          1 of 1 people found this helpful