Skip to content

Latest commit

 

History

History
 
 

process-usertasks-quarkus

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Process user task orchestration

Description

A quickstart project shows very typical user task orchestration. It comes with two tasks assigned to human actors via groups assignments - managers. So essentially anyone who is a member of that group can act on the tasks. Though this example applies four eye principle which essentially means that user who approved first task cannot approve second one. So there must be always at least two distinct manager involved.

This example shows

  • working with user tasks
  • four eye principle with user tasks

  • Diagram Properties (top)

  • Diagram Properties (bottom)

  • First Line Approval (top)

  • First Line Approval (bottom)

  • First Line Approval (Assignments)

  • Second Line Approval

  • Second Line Approval (Assignments)

Build and run

Prerequisites

You will need:

  • Java 17+ installed
  • Environment variable JAVA_HOME set accordingly
  • Maven 3.9.6+ installed

When using native image compilation, you will also need:

  • GraalVM 19.3+ installed
  • Environment variable GRAALVM_HOME set accordingly
  • GraalVM native image needs as well native-image extension: https://www.graalvm.org/reference-manual/native-image/
  • Note that GraalVM native image compilation typically requires other packages (glibc-devel, zlib-devel and gcc) to be installed too, please refer to GraalVM installation documentation for more details.

Compile and Run in Local Dev Mode

mvn clean compile quarkus:dev

NOTE: With dev mode of Quarkus you can take advantage of hot reload for business assets like processes, rules, decision tables and java code. No need to redeploy or restart your running application.

Package and Run in JVM mode

mvn clean package
java -jar target/quarkus-app/quarkus-run.jar

or on windows

mvn clean package
java -jar target\quarkus-app\quarkus-run.jar

Package and Run using Local Native Image

Note that the following configuration property needs to be added to application.properties in order to enable automatic registration of META-INF/services entries required by the workflow engine:

quarkus.native.auto-service-loader-registration=true

Note that this requires GRAALVM_HOME to point to a valid GraalVM installation

mvn clean package -Pnative

To run the generated native executable, generated in target/, execute

./target/process-usertasks-quarkus-runner

OpenAPI (Swagger) documentation

Specification at swagger.io

You can take a look at the OpenAPI definition - automatically generated and included in this service - to determine all available operations exposed by this service. For easy readability you can visualize the OpenAPI definition file using a UI tool like for example available Swagger UI.

In addition, various clients to interact with this service can be easily generated using this OpenAPI definition.

When running in either Quarkus Development or Native mode, we also leverage the Quarkus OpenAPI extension that exposes Swagger UI that you can use to look at available REST endpoints and send test requests.

Submit a request to start new approval

To make use of this application it is as simple as putting a sending request to http://localhost:8080/approvals with following content

{
    "traveller" : {
        "firstName" : "John",
        "lastName" : "Doe",
        "email" : "[email protected]",
        "nationality" : "American",
        "address" : {
          	"street" : "main street",
          	"city" : "Boston",
          	"zipCode" : "10005",
          	"country" : "US"
        }
    }
}

Complete curl command can be found below:

curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"traveller" : { "firstName" : "John", "lastName" : "Doe", "email" : "[email protected]", "nationality" : "American","address" : { "street" : "main street", "city" : "Boston", "zipCode" : "10005", "country" : "US" }}}' http://localhost:8080/approvals

Show active approvals

curl -H 'Content-Type:application/json' -H 'Accept:application/json' http://localhost:8080/approvals

Show tasks

curl -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8080/approvals/{uuid}/tasks?user=admin&group=managers'

where {uuid} is the id of the given approval instance

Complete first line approval task

curl -X POST -d '{"approved" : true}' -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8080/approvals/{uuid}/firstLineApproval/{tuuid}?user=admin&group=managers'

where {uuid} is the id of the given approval instance and {tuuid} is the id of the task instance

Show tasks

curl -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8080/approvals/{uuid}/tasks?user=admin&group=managers'

where {uuid} is the id of the given approval instance

This should return empty response as the admin user was the first approver and by that can't be assigned to another one.

Repeating the request with another user will return task

curl -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8080/approvals/{uuid}/tasks?user=john&group=managers'

Complete second line approval task

curl -X POST -d '{"approved" : true}' -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8080/approvals/{uuid}/secondLineApproval/{tuuid}?user=john&group=managers'

where {uuid} is the id of the given approval instance and {tuuid} is the id of the task instance

This completes the approval and returns approvals model where both approvals of first and second line can be found, plus the approver who made the first one.

{
	"approver":"admin",
	"firstLineApproval":true,
	"id":"2eeafa82-d631-4554-8d8e-46614cbe3bdf",
	"secondLineApproval":true,
	"traveller":{
		"address":{
			"city":"Boston",
			"country":"US",
			"street":"main street",
			"zipCode":"10005"
		},
		"email":"[email protected]",
		"firstName":"John",
		"lastName":"Doe",
		"nationality":"American"
	}
}

You should see a similar message after performing the second line approval after the curl command

{"id":"f498de73-e02d-4829-905e-2f768479a4f1", "approver":"admin","firstLineApproval":true, "secondLineApproval":true,"traveller":{"firstName":"John","lastName":"Doe","email":"[email protected]","nationality":"American","address":{"street":"main street","city":"Boston","zipCode":"10005","country":"US"}}}