In this example we will add one more BPMN 2.0 component, the Gateway path. Actually there are two types of Gateways:
A Diverging Gateway which allows you to create branches much like you did with jBPM 3 Fork Node
jbpm 5 jbpm5 tutorial jboss example
There are three types of Diverging Gateway  supported:

  •     AND or parallel means that the control flow will continue in all outgoing connections simultaneously.
  •     XOR or exclusive means that exactly one of the outgoing connections will be chosen. The decision is made by evaluating the constraints that are linked to each of the outgoing connections.
  •     OR or inclusive means that all outgoing connections whose condition evaluates to true are selected.

A Converging Gateway which allows you to synchronize multiple branches. (You can think about it like a jBPM 3 Join Node).
jbpm 5 jbpm5 tutorial jboss example
There are two types of Converging Gateways currently supported:

  •     AND or parallel means that is will wait until all incoming branches are completed before continuing.
  •     XOR or exclusive means that it continues as soon as one of its incoming branches has been completed.

    
Having cleared this concept we will create the following process which simulates a decision point where the process execution can take two differents paths depending on a condition:
jbpm 5 jbpm5 tutorial jboss example
On, now within the firstclass Script Task just define the following Textual Action:

System.out.println("We are flying in First class");	

While in the economy define the following Textual Action:

System.out.println("We are flying in Economy class");	

Ok, now click on the Diverging path Node. jbpm 5 jbpm5 tutorial jboss example

In the Properties tab, specify XOR as type, since we want to select only one condition:
(You will need to hit the refresh button or reselect the bpmn process in order to let Eclipse show the Constraints property)
Now click on the Constrainst button
jbpm 5 jbpm5 tutorial jboss example
There you need to specify the two conditions so that the engine can choose where the process will continue:
jbpm 5 jbpm5 tutorial jboss example
In the first constraint set the following Code condition:

jbpm 5 jbpm5 tutorial jboss example
While on the second one set this other following Code condition:
jbpm 5 jbpm5 tutorial jboss example
Ok now let's define at process level the variable money. (Just click to any place in the graph where no nodes are contained)
There  click on the "Variables" button and define the variable money as Integer with a value of your like.
jbpm 5 jbpm5 tutorial jboss example
That's all. Now running your process will select the path according to the predefined variable money.
In the next tutorials we will see more in details how to apply Rules and Human Tasks to your jBPM 5 project. Stay tuned with jBPM 5 !!

0
0
0
s2smodern