{{announcement.body}}
{{announcement.title}}

Using Pluggable HumanTask Assignment Strategy in jBPM 7

DZone 's Guide to

Using Pluggable HumanTask Assignment Strategy in jBPM 7

How to use pluggable HumanTask assignment strategy in jBPM7. Breaking down multiple strategies like potential owner busyness, business rules, and RoundRobin.

· Open Source Zone ·
Free Resource

jBPM 7 release provides logic to find the best suitable user to assign the task. Multiple assignment strategies are supported in this release,

  • Potential owner busyness strategy (default)
  • Business Rules Strategy
  • RoundRobin Strategy

1. Potential Owner Busyness Strategy:

This strategy makes sure that the least loaded user from the potential owner list will be selected as task owner. To make this strategy work effectively we need to provide groups of the users.It can be done by using UserInfo configured in the environment. To load user group details we can use org.jbpm.ht.userinfo option while server startup. We can load user and group mapping from DB or from LDAP. We can load user group details from the file as well.We have to create a file with a name jbpm.user.info.properties in the application classpath.

2. Business Rules Strategy

This strategy promotes the use of rules(Drools) to select the actual owner of the task. We have to provide coordinates(G.A.V) of the project which has rules. Based on the condition defined in rule Task owner will be selected. This strategy supports dynamic updates of the rules through of KieScanner APIs. It incrementally updates kieBase once a new version of the KJAR is available.

Supported Parameters with Business Rules Strategy:

  • org.jbpm.task.assignment.rules.releaseId
    ○ required - parameter that points the GAV(GroupID:ArtifactID: Version) of the KJAR which has rules specific to task assignment.
  • org.jbpm.task.assignment.rules.scan
    ○ optional - pool interval for the scanner the configured maven repository to check the new version of KJAR. This interval should be defined in milliseconds.
  • org.jbpm.task.assignment.rules.query
    ○ optional - drools query can be used to retrieve results - if not given all assignment objects are taken from working memory.

Along with custom conditions in rules, we can use Task data for task assignment in BusinessRule strategy.  Following Human Task data we can use in business rule strategies:

  •  Potential owners of tasks
  • Task data (input variables)
  • task properties (name, description, project, priority,.. etc)

Sample rule for BusinessRule strategy look like as

rule "High priority to Admin"
    when
           Task(priority > 6, priority < 50)
    then
           System.out.println("Admin gets high priority tasks");
           insert(new Assignment("admin"));
end


rule "Assign to John if task input name is for him and potentialOwners contains john"
    when
        $task : Task()
        PeopleAssignments(potentialOwners contains new UserImpl('john')) from $task.getPeopleAssignments()
        Task(taskData.taskInputVariables['name'] == "john tasks")
    then
        System.out.println("Selecting john as task name input is john and potentialOwners contains him");
        insert(new Assignment("john"));
end

3. RoundRobin Strategy

Human tasks can now be assigned to groups and/or lists of individuals, in a round-robin manner. Updating/changing a task's list of potential owners will cause the underlying queue to be updated the next time an instance of that task is auto-assigned.

How to Use a Pluggable Task Assignment Strategy:

  • Task assignment is disabled by default and it can be enabled using below system property:

            -Dorg.jbpm.task.assignment.enabled=true

  • Define the task assignment strategy:

-Dorg.jbpm.task.assignment.strategy =PotentialOwnerBusyness/BusinessRule/RoundRobin

If we didn't provide org.jbpm.task.assignment.strategy so PotentialOwnerBusyness strategy will be used by default.

  • To  resolve group assigned to users we need to select user info implementation by using  below system property:
    -Dorg.jbpm.ht.userinfo=db/ldap

 

Topics:
jbpm core engine api

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}