JbpmForkFAQ

Version 6

    Question:  What does the default fork handler do?

     

    Answer:  The default fork handler creates a child token for a branch and calculates the next state for that branch.  It does this for each branch in the fork.

     

    Question:  Is the default fork handler synchronous or asynchronous?

     

    Answer:  The default fork handler is synchronous.

     

     

    Question:  I have some very long tasks that I need run concurrently. How do I have multiple tasks running concurrently in a fork?  Is this possible if the default fork handler is synchronous?  Do I have to write my own fork handler?

     

    Answer:  You can have multiple tasks running concurrently in a fork.  A custom fork handler is not needed. 

     

    Step-by-step of concurrent task execution in a fork (There is a sample process definition xml below):

     

    - This is a fork with two branches, each branch having one state before the join.

     

    - There is a custom action handler on the entry to the states in each branch.

     

    - The default fork handler creates the first child token for the first branch, and calculates the state for that first branch.

     

    - The default fork handler calls the custom action handler for the first branch.

     

    - The custom action handler sends a JMS message passing the token ID for that branch of the fork. 

     

    - The custom action handler is then done, and the default fork handler is finished calculating the state for that branch.

     

    - The default fork handler then moves on to the next branch of the fork and repeats the process.

     

    - There is a custom message driven bean outside of jBPM that picks up the JMS message and starts the long running task. 

     

    - Once the task completes, the message driven bean calls ExecutionService.endOfState(tokenID). 

     

    - jBPM then calculates the next state for that branch. (in this example, it would go to the join).

     

    - Once all of the child tokens are at the join, then the next state is calculated.

     

     

     

     

     

     

    Question:  Can I have more than 10 branches?  The code appears to only support 10.

     

    Answer:  There are named place holders for 10 branches, but this is not a limit.  If there are more than 10 branches, then they will be numbered.

     

     

    Question:  I am using the ExecutionContext, and when the folk handler creates the child token, the token inside of the ExecutionContext changes!  Why is this?

     

    Answer:  In jBPM 2, the ExecutionContext is re-used.  In jBPM 3, a new ExecutionContext is created.

     

     

    Question:  If the first branch in the fork has no state, the other branches are not created/executed.

     

    Answer:  This is a known bug.  It will be fixed in the final release of jBPM 3.  If you are using jBPM 2, the work-around is to have states for all branches of the fork or ask for an unofficial patch (tested by several people) via ronald (@) jbpm dot org