Chapter 6. Hello World Business Rule
Since Red Hat JBoss BPM Suite comes with Red Hat JBoss BRMS integrated, this chapter provides an introduction to how business rules work and integrate into Red Hat JBoss BPM Suite.
You will add a new Business Rule Task to the Hello World process, which will fire (check) a business rule of a particular business rule group.
Note that this is a very simple integration case and in production you might need to use a more advanced concept and techniques, such as decision tables. For more information on business rules and BRMS see the Red Hat JBoss BRMS User Guide.
6.1. Creating Business Rule
Business rules are defined as when-then statements: when something is true, then something happens (for example, when the person is older than 18, they can access the particular content). Business rules are stored in DRL files.
To define the helloworldrule
business rule in the Hello World project, do the following:
In Project Explorer, select the
helloworld
organizational unit, thehelloworldrepo
repository, theHelloWorld
project, and thedefault
package.Package SelectionMake sure to select the
default
package. Selection of an incorrect package causes the deployment to fail.Create the DRL file:
- On the perspective menu, click New Item → DRL file.
-
In the Create new DRL file dialog box, define the resource name as
helloworldrule
and check that the package is set toorg.bpms.helloworld
. - Click Ok.
In the displayed DRL editor with the
helloworldrule.drl
file, define the rule:rule "helloworldrule" ruleflow-group "helloworldgroup" when then System.out.println("Hello World!"); end
This rule does not define any when condition, that is, it will always be true when fired (called to execute) and the
Hello World!
phrase will be printed.- Click Save.
- The Save this item prompt is displayed. Enter the Check-in comment and click Save.