4 Replies Latest reply on Jan 16, 2012 6:28 PM by saig0

    Can parent and child process use the same processInstanceId?

    sandeep kumar Newbie

      Hi JBPM Users,

      I have a query, The Problem description is as follows “I have a main process that contains a re-usable sub process. When the process gets executed there will be two processInstanceId; one for parent and other one for child. My question is

      1) Is it possible that both the process generates same process instance id?

      2) Can Child process get parent processInstance Id? Is there any API for that (Because we can get that by setting the process parameter)?

      3)   Can Parent process get child processInstance Id?

        • 1. Re: Can parent and child process use the same processInstanceId?
          Tihomir Surdilovic Master

          No. Maybe use an embedded/ad-hoc subprocess instead.

          • 2. Re: Can parent and child process use the same processInstanceId?
            saig0 Newbie

            Why you need the process instance id of child / parent? That is your use case?

             

            In my project I need the relation between child and parent process instance for process monitoring. There is no api to get this information but I could create a process event listener for my case. After the re-usable sub process node is triggered  the process instance id of sub-process store in the sub-process node. The listener read this information and store it for application.

             

             

            @Override
                public void afterNodeTriggered(ProcessNodeTriggeredEvent event)
                { 
                    if (event.getNodeInstance() instanceof SubProcessNodeInstance)
                    {
                        long processInstanceId = event.getProcessInstance().getId();
            
                        SubProcessNodeInstance subProcessNodeInstance = (SubProcessNodeInstance) event.getNodeInstance();
                        long subProcessInstanceId = subProcessNodeInstance.getProcessInstanceId();
            
                        SubProcessNode subProcessNode = (SubProcessNode) event.getNodeInstance().getNode();
                        String subProcessId = subProcessNode.getProcessId();
                        String subProcessVersion = processInstanceManager.getProcessInstance(subProcessInstanceId)
                                .getProcess().getVersion();
                        String nodeName = subProcessNode.getName();
                        
                        // store information
                    }
                }
            

             

            It works but it would be much better with api access.

            • 3. Re: Can parent and child process use the same processInstanceId?
              sandeep kumar Newbie

              Thanx for your reply.

              In my use case I have to show some more information which resides outside jbpm tables. My process contains some reusable sub-process. the running instance may halt either on main process or on child process. So, Iam looking some API  which gives me child/process insatnce id based on parent/child id.

               

               

              Regards

              sandeep

              • 4. Re: Can parent and child process use the same processInstanceId?
                saig0 Newbie

                So maybe you can try my process event listener or create a feature request ;-)