[jboss-user] [jBPM] - ProcessEventListener methods executed twice

Sebastien Lelarge do-not-reply at jboss.com
Tue Oct 18 12:06:16 EDT 2011


Sebastien Lelarge [http://community.jboss.org/people/slelarge] created the discussion

"ProcessEventListener methods executed twice"

To view the discussion, visit: http://community.jboss.org/message/632356#632356

--------------------------------------------------------------
Hi,

I am playing with ProcessEventListener implementation and I have the feeling that methods are executed twice for the same Node.
For now, I am just tracing a message when a method is triggered and I get it twice in the log file !
My goal is to fire rules when I reach a Rule Task Node because I have issues if I fireAllRules at process startup...
What's wrong ?

Here's how I initialize the ksession
{code}
ksession =  JPAKnowledgeService.newStatefulKnowledgeSession(base, kconfig, 
JPAWorkingMemoryDbLogger wkfLogger = new JPAWorkingMemoryDbLogger(ksession);

ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));

ksession.addEventListener(new JbpmProcessEventListener(ksession));
{code}

here's the code of my EventListener:
{code}
 import org.drools.event.process.ProcessCompletedEvent;
import org.drools.event.process.ProcessEventListener;
import org.drools.event.process.ProcessNodeLeftEvent;
import org.drools.event.process.ProcessNodeTriggeredEvent;
import org.drools.event.process.ProcessStartedEvent;
import org.drools.event.process.ProcessVariableChangedEvent;
import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.workflow.core.node.RuleSetNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JbpmProcessEventListener implements ProcessEventListener {

                private StatefulKnowledgeSession session;
                private static Logger logger = LoggerFactory.getLogger(JbpmProcessEventListener.class);

                public JbpmProcessEventListener(StatefulKnowledgeSession ksession){
                               session = ksession;
                }

                public void beforeVariableChanged(ProcessVariableChangedEvent event) {
                }

                public void beforeProcessStarted(ProcessStartedEvent event) {
                }

                public void beforeProcessCompleted(ProcessCompletedEvent event) {
                }

                public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) {

                    logger.debug("beforeNodeTriggered: " + event.getNodeInstance().getNode().getClass());
                    logger.debug("beforeNodeTriggered: " + event.getNodeInstance().getNode().getName());
                    if (event.getNodeInstance().getNode() instanceof RuleSetNode) {
                        session.fireAllRules();
                    }
                }

                public void beforeNodeLeft(ProcessNodeLeftEvent event) {
                 }

                public void afterVariableChanged(ProcessVariableChangedEvent event) {
                }

                public void afterProcessStarted(ProcessStartedEvent event) {
                }

                public void afterProcessCompleted(ProcessCompletedEvent event) {
                }

                public void afterNodeTriggered(ProcessNodeTriggeredEvent event) {
                }

                public void afterNodeLeft(ProcessNodeLeftEvent event) {
                }

}
{code}
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/632356#632356]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111018/5b4d0a5f/attachment.html 


More information about the jboss-user mailing list