12 Replies Latest reply on May 16, 2011 5:59 AM by Ayusman Dikshit

    Dynamic parallel executions

    Ayusman Dikshit Newbie

      All,

      I have a requirement to create multiple parallel executions, based on a database value.

      Inside each execution, the set of user approvals can be sequential or parallel. The number of  users in each path of execution and whether parallel or sequential is decided again by reading a database table.

       

      Does Jbpm provide features for such scenarios (meaning dynamic number of execution paths etc)?

       

      TIA

        • 1. Dynamic parallel executions
          Esteban Aliverti Master

          Maybe you can use a "Multiple Instance" node with a Reusable Subprocess in it. Take a look at this examples to see how Multiple Instance and Reusable Subprocess nodes work:

           

          https://github.com/esteban-aliverti/JBPM-Samples

          • 2. Dynamic parallel executions
            bpmn2user Expert

            Ayusman Dikshit:

             

            Here is a simple example for multiple instances component:

            http://community.jboss.org/people/bpmn2user/blog/2011/03/05/jbpm5--multiple-instances

             

             

            Here loop condition can be set using a value from database either using a script node or programmatically.

            • 3. Dynamic parallel executions
              byungwoojun Newbie

              I have used the multiple instances which depends on the incoming collection size. What if the multiple instance node is set parallel and the collection size is huge? I don't want to consume all the java resources (e.g., CPU, memory, etc.) when tasks inside the multiple instance node are not fast . Is there any built-in throttling control for the multiple instance node?

               

              If there is a jBPM5 configuration controlling the max thread number for parallel (let's say 10) and the collection size is 1000, does the process slows down spawning processing? Also, I read the JBPM-3015 (Core Engine should support multi-threading) open issue, which is targeted for jBPM 5.1. What does it mean in this parallel multi instance handling?

               

              thanks,

              bwj

              • 4. Dynamic parallel executions
                Ayusman Dikshit Newbie

                I looked at the answers given by you guys.

                I only see solutions that are in BPMN notation (I am not sure how to execute BPMN process definition files in jbpm).

                 

                Also I was trying to understand how this is done in jbpm 4.4, using the jpdl plugin.

                 

                Any suggestions?

                • 5. Dynamic parallel executions
                  Ayusman Dikshit Newbie

                  I looked at the answers given by you guys.

                  I only see solutions that are in BPMN notation (I am not sure how to execute BPMN process definition files in jbpm).

                   

                  Also I was trying to understand how this is done in jbpm 4.4, using the jpdl plugin.

                   

                  Any suggestions?

                  • 6. Dynamic parallel executions
                    Esteban Aliverti Master

                    Parallel execution in jBPM5 means "busines parallel execution". Each instance will run in sequence. So, if you have 2 elements in the loop collection, the first isntance will run until it finnishes, or reaches a wait-state. Only then, the second instance will start. Everything happen in a single execution thread.

                    • 7. Dynamic parallel executions
                      Esteban Aliverti Master

                      Sorry, I was talking about jBPM 5. No idea if there is something similar in jBPM 4.x.

                      • 8. Dynamic parallel executions
                        byungwoojun Newbie

                        Hi Esteban, I was interested in how jBPM manages threads for the parallel gateway and multiple instance parallel underneath. It is very nice to know that. Thanks! I saw some knowledgebase configuration, setting up max thread number. Even though we set up a higher number of max thread, all happens in a single thread for parallel gateway and multiple instance. It means jBPM 5 simulates parallel behaviors using a single thread. Is my understanding correct? I am worried about performance. I think many believe that parallel execution happens concurrently.

                         

                        Thanks again.

                        bwj

                        • 9. Dynamic parallel executions
                          Esteban Aliverti Master

                          AFAIK, the max thread number configuration is related to KnowledgeBase partitioning and it has nothing to do with jBPM. jBPM 5 always uses a single execution thread (unless you are using timers). When the execution reaches a diverge gteway, or a multiple instance node, one of the paths is selected and executed to its end. After the path is completed (and if the process is not yet completed), the second path is selected, and so on.

                           

                          This behavior has some implications. Think for example in this scnenario:

                           

                          Selection_034.png

                          Even when you have a parallel diverge gateway, only one of the tasks is going to be executed (and you don't know which one!!). The thing is that I'm using an XOR converge gateway, so when the first task is completed (let say Task B), the gateway will continue the execution to the end node. So, in this case, Task A will not be executed. If we were using multi-threading, both Tasks will start, but strange things will happen if the process ends but one of the path is still running (I'm using just one task in each path, but things could be much more complicated) . 

                          • 10. Dynamic parallel executions
                            byungwoojun Newbie

                            Using the XOR converge gateway was a clever way to test the thread behavior. I'd like try it myself.

                             

                            If there is no way to execute the parallel gateway concurrently in jBPM, I am wondering how it solves a busienss case as follows:

                             

                            I had a business case...some tasks (let's say searching for some in various ways and from multiple applications) need be triggered concurrently. And, if one of the parellel paths hits some exceptions (or some other business conditions) whichever comes first, stop all the running parallel processing and move to the next steps in the process flow.

                             

                            I solved the use case using BPEL with BPMN 1.x facade from a commerical product before, where the parallel gateway processes were handled concurrently.

                             

                            e.g., I defined a sub-process. In there, I defined an event (e.g., error or else) node on each parallel path, and it was linked (promoted) the event to a sub-process level event which is attached to the subprocess boarder. The outer event handled cleanup and move to the next node/subprocess.

                             

                            I am not sure if I explained the case efficiently or not... Anyway...

                             

                            I think the above business case in jBPM could be very inefficient. Also, I think the sequencing behavior is because a jBPM porcess uses a process caller thread.

                             

                            Thanks for sharing your insight!

                            bwj

                            • 11. Dynamic parallel executions
                              Ayusman Dikshit Newbie

                              In jbpm 4.4 I am using a "foreach" construct to create parallel executions dynamically i.e. based on some inputs.

                              Till now it's all in initial testing stages.

                               

                              Has anybody tried this yet?

                               

                              Thanks.

                              • 12. Dynamic parallel executions
                                Ayusman Dikshit Newbie

                                Hi Esteban,

                                 

                                 

                                here is my business case.

                                 

                                An admin user selects a set of approvers for a particular business decision. The selection of the approvers list will happen before the start of the workflow, but the number of approvers is NOT constant.

                                 

                                 

                                So when the workflow starts, it reads a database value and passes the values to the foreach construct like this:...

                                 

                                 

                                   <foreach g="203,38,48,48" in="#{users}" name="foreach1" var="user">

                                 

                                      <transition g="-34,-17" name="to PreProcess" to="PreProcess"/>

                                 

                                   </foreach>

                                 

                                   <java class="test.tasks.test1.ProcessJava" g="359,35,92,52" method="preProcess" name="PreProcess">

                                 

                                         <arg><object expr="#{user}"/></arg>

                                 

                                      <transition g="-28,-17" name="to userTask" to="userTask"/>

                                 

                                   </java>

                                 

                                   <task g="543,37,92,52" name="userTask" assignee="#{user}">

                                 

                                      <transition g="-76,-18" name="to postProcess" to="postProcess"/>

                                 

                                   </task>

                                 

                                   <java class="test.tasks.test1.ProcessJava" g="542,121,92,52" method="postProcess" name="postProcess">

                                 

                                         <arg><object expr="#{user}"/></arg>

                                 

                                      <transition g="-48,-18" name="to merge" to="merge"/>

                                 

                                   </java>

                                 

                                   <join g="565,213,48,48" multiplicity="#{users.size}" name="merge">   

                                 

                                      <transition g="-53,-18" name="to allDone" to="allDone"/>

                                 

                                   </join>

                                 

                                 

                                Will this be good enough?

                                 

                                 

                                Thanks,

                                 

                                Ayusman