Chapter 21. Process Execution Server Configuration

21.1. Assignment Rules

Assignment rules are rules executed automatically when a Human Task is created or completed. This mechanism can be used to assign a Human Task automatically to a particular user of a group or prevent a user from completing a task in case of missing data.

21.1.1. Defining Assignment Rules

To define assignment rules:

  1. In the DEPLOY_DIR/standalone/deployments/business-central.war/WEB-INF/classes/ directory, create one or both of the following files and define the assignment rules in these files:

    • default-add-task.drl: In this file, define the rules to be checked when the Human Task is created.
    • default-complete-task.drl: In this file, define the rules to be checked when the Human Task is completed.

Example 21.1. Example default-complete-task.drl File

package defaultPackage

import org.kie.api.task.model.Task;
import org.kie.api.task.model.User;
import org.kie.api.task.model.Status;
import org.kie.api.task.model.PeopleAssignments;
import org.jbpm.services.task.rule.TaskServiceRequest;
import org.jbpm.services.task.exception.PermissionDeniedException;
import org.jbpm.services.task.impl.model.*;
import java.util.HashMap;
import java.util.List;


global TaskServiceRequest request;

rule "Don't allow Mary to complete task when rejected"
  when
    $task : Task()
    $actualOwner : User( id == 'mary') from $task.getTaskData().getActualOwner()
    $params : HashMap(this["approved"] == false)
  then
    request.setAllowed(false);
    request.setExceptionClass(PermissionDeniedException.class);
    request.addReason("Mary is not allowed to complete task without approval.");
end

If user mary is one of the potential owners of a Human Task, the task will be automatically assigned to this user.

21.2. Mail Session

A mail session defines mail server properties and is used for sending emails, for example when using an Email Service Task or sending and receiving email notifications of Human Task escalation.

For more information, see the Email Task Attributes section of the Red Hat JBoss BPM Suite User Guide.

21.2.1. Setting up Mail Session

To set up a mail session for the execution engine:

  1. Open the appropriate profile configuration file, standalone.xml or host.xml.
  2. Add the mail session to the urn:jboss:domain:mail:1.2 subsystem:

    <subsystem xmlns="urn:jboss:domain:mail:1.2">
      <!-- omitted code -->
    
      <mail-session jndi-name="mail/jbpmMailSession" debug="true" from="bpms@company.com">
        <smtp-server outbound-socket-binding-ref="bpmsMail"/>
      </mail-session>
    </subsystem>
  3. Define the session outbound socket:

    <outbound-socket-binding name="bpmsMail">
      <remote-destination host="localhost" port="12345"/>
    </outbound-socket-binding>