4 Replies Latest reply on Jun 18, 2007 2:38 PM by Edward Staub

    Help with concurrent subprocess instances!

    Vladyslav Kosulin Newbie

      I am pretty new to jBPM, and tried to find solution in forums and wike without much success.
      Here is what I need:
      I have a single (reusable) process which processes a single file with a given name.
      To be able to run this process I define a superprocess with task node for user to provide the file name and this process as subprocess. This causes no problems.
      I also need to create another process which would take all file names from, say, a specified directory, create sub-process instances for every file, wait for all subprocess instances to finish, and report results from every subprocess to a user for further decision. I do not know how many files there are. This sounds like fork and join with variable number of tokens. How can I implement it? And how to pass parameters in this case?
      Also, because all these forked instances have the same process definition, I could try to run concurrent instances of a single transition (I found a reference that this is possible), but how to do this?
      And is there way to reflect this concurrency in GPD diagram?


        • 1. Re: Help with concurrent subprocess instances!
          Ronald van Kuijk Master

          Search better....this kind of fork has been discussed before... use various search technologie (e.g. google) or maybe look in the wiki to find an answer.

          • 2. Re: Help with concurrent subprocess instances!
            Roberto Alonso Ramos Zapata Newbie

            No, theres no way to show this on the diagram, but like you said, it is done using a fork and a join, but... no the normal fork that comes with jbpm, you need to create your own implementation with a node.

            I have in an application this, but I did not code it so I can't hand it to you, but let me ask the programer if theres no problem with posting it.

            Also you can look in google for an implementation of the fork done by "Alfresco Content Manager" programers, I believe it does what your trying to achive.

            • 3. I am totally lost :-(
              Vladyslav Kosulin Newbie

              I am still not sure. If I create a custom form, like foreachfork from Wiki, that means I create at least 2 ways of execution.
              But what I need is to create multiple tokens for the same way of execution (run the same subprocess) and start them.
              May be, instead of fork, I just need to implement a node with ActionHandler which creeates tokens for each instance of subprocess and starts them?

              But then, how do I wait for all instances to finish before proceeding to next node? Should they send events, and my main process should have a state which listens until all subprocesses report?

              Another problem is how business analyst can watch the process status if no diagram can be created to reflect the flow?

              Googling for "Alfresco Content Manager" brings nothing :-(

              • 4. Re: Help with concurrent subprocess instances!
                Edward Staub Expert

                Fork (as in ForEachForkActionhandler) is what you want.
                There's nothing preventing multiple tokens "for the same way of execution". The fact that they CAN be different doesn't mean they MUST be different.

                You wait for all of them to complete by having them transition to a join node (in the parent process). You don't need to do anything more.

                So in the parent process, you have a minimum sequence of:


                The fork creates as many tokens as necessary.
                When they reach the join, they will block until everyone is completed.

                -Ed Staub