Search code examples
jbpm

How to know whether a process ended in JBPM


Started a Jbpm process through StatefulKnowledgeSeesion(ksession)

    ksession.startProcess(processName);

Now I want to know, whether the process ended. How to get the end status ?..Please help


Solution

  • If you want to be notified when the process ended you can register your own listener (which extends org.drools.core.event.DefaultProcessEventListener or implement the org.kie.api.event.process.ProcessEventListener interface), and implement the "afterProcessCompleted" method:

    @Override
    public void afterProcessCompleted(ProcessCompletedEvent event) {
    
        org.kie.api.runtime.process.ProcessInstance processInstance = event
                .getProcessInstance();
        log.info("Process completed: processId=["
                + processInstance.getProcessId() + "]; processInstanceId=["
                + processInstance.getId() + "]");
    }
    

    Check Event Listeners from documentation