Information Technology Reference
In-Depth Information
Applying rules to our processes
Invoking business rules from inside a business process and vice versa can provide a lot of
power to our knowledge representation. Both components deal with decisions in two very
different ways; rules provide simple ways of representing complex solutions, where the or-
der to find said solution is not always relevant. Processes, on the other hand, focus on the
order of the steps that need to be taken to reach a goal.
Inside jBPM6, you can invoke rules and processes or even perform nested invocations,
where rules invoke processes that can then invoke other rules with very little configuration.
We will start by learning the different ways to execute rules in our business processes. In
the process-rules-examples project, you will find a test that will be used in the rest
of this section called RulesAndProcessesTest , where processes are invoked from
rules and rules from processes as well.
Gateway conditions
The simplest way to define conditions in our processes is inside an exclusive or inclusive
gateway's outgoing sequence flows. Inside sequence flows, you can determine a condition
expression to decide whether that flow should be followed or not. This condition is defined
as Java code by default in the web process designer used in Chapter 3 , Using BPMN 2.0 to
Model Business Scenarios . However, if you select Drools in the expression language attrib-
ute of the sequence flow, you can define a condition expression that will be evaluating the
rule memory with a DRL-based condition. This is quite useful to evaluate complex condi-
tions, but it depends on that all the relevant objects being "inserted" in the KIE session's
rule memory.
Business Rule tasks
The most common way of invoking rules from a process is through Business Rule tasks,
which was explained briefly in Chapter 3 , Using BPMN 2.0 to Model Business Scenarios .
In a Business Rule task, you will have to define two important things: input mappings for
the task that will determine what process variables should be made available in the KIE
session's rule memory, and a RuleFlow Group attribute that will define what group of
rules are to be invoked. In the RulesAndProcessesTest class, we invoke a process
with a Business Rule task, such as the one shown in the following diagram:
Search WWH ::




Custom Search