3 Replies Latest reply on Apr 27, 2010 5:45 AM by Deepak Agarwal

    can i fork and then join up an end-user specified number of

    Simon Massey Newbie

      I am evaluating jbpm for embedding within an insurance trading system. We have a very typical scenario where the insurance broker markets the client risk to a number of insurance companies. What markets are selected for which risks is mostly discressionary for the broker based on the particular client need. This leads me to my problem. If I were do to some swimlanes on the graphical modelling tools I don't know how many swim lanes I need until runtime as I don't now whether I need to fork to 1, 2 or 12 different subprocesses for the number of markets selected by the broker.

      I would like to fork into a set of parrellel subprocess then join them back again once each selected insurance company has given a quote. I cannot see how I would graphically model things so that a parent process "forks to a user specified number of subprocesses then joins them all back up".

      I am sure that I am missing something at a conceptual level as to how to do what I want. Can someone give me some pointers as to how to start a variable number of subprocesses and join them without having to hand code the folks and joins? Would the normal approach just be to write an action that programmatically launches the variable number of seperate processes? That would mean that I would have to "programmatically join them myself" by having a job wait monitor the spawned processes to see if they have completed and then signal the original process instance that the broker now has to pick the best quote?

      Thanks!

        • 1. Re: can i fork and then join up an end-user specified number of
          Mike M Newbie

          I have this same problem, and I am implementing a solution in the same way you have described.

           

          I have two special custom activities - one that is able to spawn multiple new processes based on some runtime criteria and another that does the join, waiting until all the spawned (child) processes are finished. I have some special process variables that I keep in the child processes that gives me  information about which parent process it belongs to (ie. execution id).

           

          When the child process finishes, I keep track of this and if my parent process is currently in the "join" step, I also signal the parent execution. My signal() method catches these signals and either continues waiting (if more child processes are still running) or take a transition (if all child processes are finished).

           

          Using a scheme like this, you'd only need one swimlane definition in the child process definition, since you would be spawning multiple instances.

          • 2. Re: can i fork and then join up an end-user specified number of
            Ronald van Kuijk Master

            No, you are not missing something. The 'for-each' in de runtime defined set is not supported at the moment. I do have an extention to the fork node available here that supports this.

             

            In combination with this there is an extension to the join where you can define the number of forked instances should reach the join before continuing.

             

            So please vote for https://jira.jboss.org/jira/browse/JBPM-2414

            • 3. Re: can i fork and then join up an end-user specified number of
              Deepak Agarwal Newbie

              We are using jbpm 4.01 & wanted to implement such dynamic fork/join. We need to run a givem sub-process x number of times (in parallel) where value of x is known only at runtime. Is it possible in jbpm 4.01? If yes, could you please point me to some sample code (java + jpdl) for it?