5 Replies Latest reply on Nov 2, 2011 8:42 AM by swiderski.maciej

    JBPM 5 Question On Mulitple Instances Node

    ossa

      Hi all,

      My requirement goes like this:

       

      1. An applicant submits an application.
      2. The application will then be routed to multiple approvers in parallel. Each approver will need to either approve or reject the application. The list of approvers will only be known at runtime.
      3. Once any approver rejects the application, the applicant will need to change and resubmit it again.

       

      I am able to achieve step2 by putting the the "approve" human task inside a "multiple instances" node. My question is when one of the approver rejects the application, how do I notify those tasks pending approval. Preferrably, I want to cancel those task since they are no longer valid.

       

      One way I could think of is to do a query of all the pending task base on the processInstanceId and skip each of them through the TaskClient. However, that does look like the best way. Any insight is appreciate

       

       

      thanks

      -Zeliang

        • 1. Re: JBPM 5 Question On Mulitple Instances Node
          ossa

          Can I put something in the exit action to accomplish this?

          • 2. Re: JBPM 5 Question On Mulitple Instances Node
            ossa

            I can really use some help here. anyone?

            • 3. Re: JBPM 5 Question On Mulitple Instances Node
              swiderski.maciej

              Hi,

               

              I can see two options:

              • as you mentioned, have an additional task after the user task (with multiplicity) that will verify the outcome and in case of rejection it will cancel all other user tasks
              • as an alternative I would give it a try with n out of m pattern with parallel & complex gateway, so the converging gateway could decide if the flow shall continue when rejection was encountered.

              HTH

              • 4. Re: JBPM 5 Question On Mulitple Instances Node
                ossa

                Hi Maciej,

                 

                thanks for the insight. I think option 1 is exactly what I was looking for.

                 

                I only know of one way to find and cancel other user tasks. below is my code. Is there other better to achieve this? Any help is appreciated. thanks !

                EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");
                Query q = emf.createEntityManager().createNamedQuery("OtherTaskByProcessInstancdId");
                q.setParameter("processInstanceId", new Long("2080"));
                List<Task> i = q.getResultList();
                TaskClient client = new TaskClient(new MinaTaskClientConnector("YetAnotherClient", new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
                client.connect("127.0.0.1", 9123);
                BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler();
                for (Task t : i) {
                   client.skip(t.getId(), "Administrator", responseHandler);
                }
                

                 

                 

                And this is my workflow

                 

                workflow.png

                • 5. Re: JBPM 5 Question On Mulitple Instances Node
                  swiderski.maciej

                  I believe that is the right way, since Human Task Service is considered an external component to the jBPM engine so you need to utilize Task Client