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
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).
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:
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.
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
There you need to specify the two conditions so that the engine can choose where the process will continue:
In the first constraint set the following Code condition:
While on the second one set this other following Code condition:
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.
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 !!
- << Prev