Business Rule Task

A Business Rule Task is used to synchronously execute one or more rules. It is also possible to call Java code or providing a work item for an external worker to complete asynchronously or invoking a logic which is implemented in form of webservices.

Using CadenzaFlow DMN Engine

You can use the CadenzaFlow DMN engine integration to evaluate a DMN decision. You have to specify the decision key to evaluate as the cadenzaflow:decisionRef attribute. Additionally, the cadenzaflow:decisionRefBinding specifies which version of the decision should be evaluated. Valid values are:

  • deployment, which evaluates the decision version which was deployed with the process version,
  • latest which will always evaluate the latest decision version,
  • version which allows you to specify a specific version to execute with the cadenzaflow:decisionRefVersion attribute, and
  • versionTag which allows you to specify a specific version tag to execute with the cadenzaflow:decisionRefVersionTag attribute.
<businessRuleTask id="businessRuleTask"
    cadenzaflow:decisionRef="myDecision"
    cadenzaflow:decisionRefBinding="version"
    cadenzaflow:decisionRefVersion="12" />

The cadenzaflow:decisionRefBinding attribute defaults to latest.

<businessRuleTask id="businessRuleTask"
    cadenzaflow:decisionRef="myDecision" />

The attributes cadenzaflow:decisionRef, cadenzaflow:decisionRefVersion, and cadenzaflow:decisionRefVersionTag can be specified as an expression which will be evaluated on execution of the task.

<businessRuleTask id="businessRuleTask"
    cadenzaflow:decisionRef="${decisionKey}"
    cadenzaflow:decisionRefBinding="version"
    cadenzaflow:decisionRefVersion="${decisionVersion}" />

The output of the decision, also called decision result, is not saved as process variable automatically. It has to pass into a process variable by using a predefined or a custom mapping of the decision result.

In case of a predefined mapping, the cadenzaflow:mapDecisionResult attribute references the mapper to use. The result of the mapping is saved in the variable which is specified by the cadenzaflow:resultVariable attribute. If no predefined mapper is set then the resultList mapper is used by default.

<businessRuleTask id="businessRuleTask"
    cadenzaflow:decisionRef="myDecision"
    cadenzaflow:mapDecisionResult="singleEntry"
    cadenzaflow:resultVariable="result" />

See the User Guide for details about the mapping.

Name of the Result Variable

The result variable should not have the name decisionResult, as the decision result itself is saved in a variable with this name. Otherwise, an exception is thrown while saving the result variable.

DecisionRef Tenant Id

When the Business Rule Task resolves the decision definition to be evaluated it must take multi tenancy into account.

Default Tenant Resolution

By default, the tenant id of the calling process definition is used to evaluate the decision definition. That is, if the calling process definition has no tenant id, then the Business Rule Task evaluates a decision definition using the provided key, binding and without a tenant id (tenant id = null). If the calling process definition has a tenant id, a decision definition with the provided key and the same tenant id is evaluated.

Note that the tenant id of the calling process instance is not taken into account in the default behavior.

Explicit Tenant Resolution

In some situations it may be useful to override this default behavior and specify the tenant id explicitly.

The cadenzaflow:decisionRefTenantId attribute allows to explicitly specify a tenant id:

<businessRuleTask id="businessRuleTask" decisionRef="myDecision"
  cadenzaflow:decisionRefTenantId="TENANT_1">
</businessRuleTask>

If the tenant id is not known at design time, an expression can be used as well:

<businessRuleTask id="businessRuleTask" decisionRef="myDecision"
  cadenzaflow:decisionRefTenantId="${ myBean.calculateTenantId(variable) }">
</businessRuleTask>

An expression also allows using the tenant id of the calling process instance instead of the calling process definition:

<businessRuleTask id="businessRuleTask" decisionRef="myDecision"
  cadenzaflow:decisionRefTenantId="${ execution.tenantId }">
</businessRuleTask>

Using a Custom Rule Engine

You can integrate with other rule engines. To do so, you have to plug in your implementation of the rule task the same way as in a Service Task.

<businessRuleTask id="businessRuleTask"
    cadenzaflow:delegateExpression="${MyRuleServiceDelegate}" />

Using Delegate Code

Alternatively, a Business Rule Task can be implemented using Java Delegation just as a Service Task. For more information on this please see the Service Tasks documentation.

Implementing as an External Task

In addition to the above, a Business Rule Task can be implemented via the External Task mechanism where an external system polls the process engine for work to do. See the section on Service Tasks for more information about how to configure an external task.

CadenzaFlow Extensions

Attributes cadenzaflow:asyncBefore, cadenzaflow:asyncAfter, cadenzaflow:class, cadenzaflow:decisionRef, cadenzaflow:decisionRefBinding, cadenzaflow:decisionRefTenantId, cadenzaflow:decisionRefVersion, cadenzaflow:decisionRefVersionTag, cadenzaflow:delegateExpression, cadenzaflow:exclusive, cadenzaflow:expression, cadenzaflow:jobPriority, cadenzaflow:mapDecisionResult, cadenzaflow:resultVariable, cadenzaflow:topic, cadenzaflow:type, cadenzaflow:taskPriority
Extension Elements cadenzaflow:failedJobRetryTimeCycle, cadenzaflow:field, cadenzaflow:connector, cadenzaflow:inputOutput
Constraints One of the attributes cadenzaflow:class, cadenzaflow:delegateExpression, cadenzaflow:decisionRef, cadenzaflow:type or cadenzaflow:expression is mandatory
The attribute cadenzaflow:resultVariable can only be used in combination with the cadenzaflow:decisionRef or cadenzaflow:expression attribute
The cadenzaflow:exclusive attribute is only evaluated if the attribute cadenzaflow:asyncBefore or cadenzaflow:asyncAfter is set to true
The attribute cadenzaflow:topic can only be used when the cadenzaflow:type attribute is set to external.
The attribute cadenzaflow:taskPriority can only be used when the cadenzaflow:type attribute is set to external.

Additional Resources