7 Replies Latest reply on Mar 11, 2008 10:11 AM by ffernandez

    modelling worklows with parallel nodes

    ajanz

      i got to model the following workflow

      i got a start node

      from start node, i want to notify three different departments to do some work. the work of the three departments should be done at the same time, when all three they got their work done, the workflow will go to an end node with a final proof. a simple workflow i think

      how can i model this using jbpm?

      thanks
      sascha

        • 1. Re: modelling worklows with parallel nodes

          Sorry, but IMHO it cannot be possible due to database problems with transactions.

          The way I tried without success was the fork/join with async nodes. Yes, the nodes are executed at the same time by JobExecutor, but there was no way to synchronize the concurrent nodes.

          Regards

          • 2. Re: modelling worklows with parallel nodes
            kukeltje

            If you have tasks it *is* possible... there 'just' seems to be an issue with concurrent async nodes in a fork/join

            • 3. Re: modelling worklows with parallel nodes
              ajanz

              ok. may be i am using tasks. but this does not still solve my problem

              i got a start node. from this point i want to deliever the workflow to three different users, each with different to do for the workflow, e.g. collect some information, make a phone call, create a document. how do i model this scenario in jbpm?

              • 4. Re: modelling worklows with parallel nodes

                Excuse me,

                Please, could you put a processdefinition example for this task node usage? How can you make the synchronization process for "when all three they got their work done, the workflow will go to an end node"? Please any suggestion would be appreciated.

                Thanks in advanced.

                • 5. Re: modelling worklows with parallel nodes

                  Hi Ronald,

                  I have tested this workflow with task-nodes but without parallel execution (task node "one" and "two" are executed in sequence):

                  import junit.framework.*;
                  import org.jbpm.*;
                  import org.jbpm.graph.def.*;
                  import org.jbpm.graph.exe.*;
                  
                  public class JbpmForkTest extends TestCase {
                  
                   JbpmConfiguration configuration = JbpmConfiguration.getInstance( "my.jbpm.cfg.xml" );
                  
                   protected void setUp() {
                   JbpmContext jbpmContext = configuration.createJbpmContext();
                  
                   ProcessDefinition pd = ProcessDefinition.parseXmlString(
                   "<process-definition name='test'>" +
                   " <start-state name='start'>" +
                   " <transition to='fork' />" +
                   " </start-state>" +
                   " <fork name='fork'>" +
                   " <transition name='first' to='one' />" +
                   " <transition name='second' to='two' />" +
                   " </fork>" +
                   " <task-node name='one' >" +
                   " <event type='node-enter'>" +
                   " <action class='JbpmSleepActionHandler'/>" +
                   " </event> " +
                   " <transition to='join'>" +
                   " </transition>" +
                   " </task-node >" +
                   " <task-node name='two' >" +
                   " <event type='node-enter'>" +
                   " <action class='JbpmSleepActionHandler'/>" +
                   " </event> " +
                   " <transition to='join'>" +
                   " </transition>" +
                   " </task-node >" +
                   " <join name='join'>" +
                   " <transition to='end' />" +
                   " </join>" +
                   " <end-state name='end' />" +
                   "</process-definition>"
                   );
                   jbpmContext.deployProcessDefinition( pd );
                   jbpmContext.close();
                   }
                  
                   public void testFork() throws Exception{
                  
                   JbpmContext jbpmContext = configuration.createJbpmContext();
                   ProcessInstance pi = jbpmContext.newProcessInstance( "test" );
                   pi.signal();
                   jbpmContext.save( pi );
                   jbpmContext.close();
                   }
                  
                  }
                  
                  
                  import org.jbpm.graph.def.ActionHandler;
                  import org.jbpm.graph.exe.ExecutionContext;
                  
                  public class JbpmSleepActionHandler implements ActionHandler {
                  
                   public void execute(ExecutionContext executionContext) throws Exception {
                   System.err.println ( "sleep " + executionContext );
                   Thread.sleep( 10000 );
                   System.err.println ( "wakeup " + executionContext );
                   }
                  }
                  
                  


                  Thanks Ronald

                  • 6. Re: modelling worklows with parallel nodes

                    What database is in use?
                    If it's HSQLDB, I'm with ffernandez - don't do it.
                    You need a database that supports transaction isolation.
                    I think there's now a note to this effect in the user guide, but I can't find it now.

                    • 7. Re: modelling worklows with parallel nodes

                      I'm using MySql. Here is my Hibernate configuration:

                       <!-- JDBC connection properties (begin) -->
                       <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
                       <property name="hibernate.connection.url">jdbc:mysql://...</property>
                       <property name="hibernate.connection.username">...</property>
                       <property name="hibernate.connection.password">...</property>
                       <property name="hibernate.connection.isolation">2</property>