6 Replies Latest reply on Mar 6, 2015 6:01 AM by Vladimir Vinn

    Process can't complete itself

    Vladimir Vinn Newbie

      Hello everyone!

      I'm using JBPm 6.2.0.CR4

       

      I use custom workitem handlers. In those handlers I delegate an actual workitem processing to a separate thread, and in that thread I call ksession.getWorkItemManager().completeWorkItem().

      I assume that process should be automatically completedm when all workitems are completed. But this does not happen. And I dont have and idea why.

      If I call completeWorkItem in executeWorkItem() method of WorkItemHandler then everything works fine.

       

      May be you have any ideas?

      Thank you!

        • 1. Re: Process can't complete itself
          Maciej Swiderski Master

          could you provide an more concrete example as that should work assuming completeWorkItem finishes without an error.

           

          HTH

          • 2. Re: Re: Process can't complete itself
            Vladimir Vinn Newbie

            The case is:

             

            1. Procesess is started

            StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) deploymentService.getDeployedUnit(JBPM_PROCESSES_DEPLOYMENT_ID)
                            .getRuntimeManager().getRuntimeEngine(ProcessInstanceIdContext.get()).getKieSession();
                    ksession.startProcess(processName, params);
            

             

            Each workitem is handled by a same type of WorkItemHandler

            2. WorkItemHandler sends a message with neede info plus process instance ID via JMS to a custom event processor

            3. Processor processes the message (does some logic) and sends a similar response via JMS to response handler

            4. This Response handler completes the workitem

            StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) deploymentService.getDeployedUnit(JBPM_PROCESSES_DEPLOYMENT_ID).getRuntimeManager()
                            .getRuntimeEngine(ProcessInstanceIdContext.get(gateActionResponseMessage.getProcessId())).getKieSession();
                    ksession.getWorkItemManager().completeWorkItem(gateActionResponseMessage.getWorkItemId(), results);
            

            5. Next workItem is handled in a similar way (pt. 2 - 4)

             

            After all workitems are completed, i assume the process must complete also. But is does not.

            • 3. Re: Process can't complete itself
              Maciej Swiderski Master

              exactly, that should make the process instance completed if there are not other nodes in line.  Things to verify:

              - does processId is correct process instance id?

              - does the work item id points to the correct work item?

              - how do you verify if process instance is active?

               

              to trace it you could register DebugProcessEventListener to see what is invoked and in what order.

               

              HTH

              1 of 1 people found this helpful
              • 4. Re: Re: Process can't complete itself
                Vladimir Vinn Newbie

                - process ID and workitem ID are correct.

                - the signs that process is still alive are:

                • it is under "Active" tab in the console
                • there is still respective record in SESSIONINFO (i use PER_PROCESS_INSTANCE strategy)
                • there are no records of EndEvent for the process in NODEINSTANCELOG
                • 5. Re: Process can't complete itself
                  Maciej Swiderski Master

                  Vladimir,

                   

                  would it be possible to get a reproducer to see what can be the issue?

                  • 6. Re: Process can't complete itself
                    Vladimir Vinn Newbie

                    Hi Maciej!

                     

                    Actualy, issue has gone today on it's own. I agree with you that there should be no flaws from jbpm side in the scenario I described above.

                    I guess the reason was in distributed tx management in our app, which was fixed.

                    I really have no idea what caused and solved this issue)

                     

                    Thank you for your advice. It helped to understand deeply what's going on.

                    Consider this solved.