1 Reply Latest reply on Jun 15, 2015 8:16 AM by vinniman

    Another abort process instance issue or what do I do wrong?

    vinniman

      Hello everyone!

       

      I have a case where I need to terminate the process execution upon any Exceptoin uccurred during WorkItem processing (with custom ASYNC WorkItemHandlers). Basically like WorkItemHandler fires request, and request processor completes WorkItem afret processing the request.

       

      First I thought that just calling workItemManager.abortWorkItem() will do the job and the process will terminate, but no! the process continues.

       

      Then I tried to terminate the process calling ksession.abortProcessInstance(workItem.getProcessInstanceId()) in my request processor. Process terminates but the next WorkItem after a failed one IS STILL EXECUTED (why????)


      Also I tried to terminate the process with overriding abortWorkItem() method in my handler and calling ksession.abortProcessInstance(workItem.getProcessInstanceId()) there.

      This one partially worked, because it needed the same method call request processor like above or it would make no effect at all. In that case no additional workItems were executed but the process was not terminated and kept hanging forever,

       

      I found that all this termination stuff is just setting termination flags and not actually terminating anything. Who reacts on that flags and actually terminates the process instance?

       

      Help me with proper process instance termination scenario!

       

      Thanks in advance!

       

      P.S: i'm on 6.2.0.Final

        • 1. Re: Another abort process instance issue or what do I do wrong?
          vinniman

          Found the solution.

           

          Using this guide Chapter 22. Exception Management I created an error event inside my process definitions and in request processor I fire this event to the process and then terminate it.

          Process terminates and no additional workitems execute.

           

                    ((org.drools.core.process.instance.WorkItemManager)  ksession.getWorkItemManager()).signalEvent(ERROR_EVENT, workItem, gateActionResponseMessage.getProcessId());
                    ksession.abortProcessInstance(message.getProcessId());
          

           

          If only fire an event without manual process termination - process flow continues.