Skip to content

Latest commit

 

History

History
182 lines (119 loc) · 6.18 KB

File metadata and controls

182 lines (119 loc) · 6.18 KB

Process with persistence powered by Infinispan

Description

A quickstart project that processes deals for travellers. It utilizes process composition to split the work of:

  • submitting a deal
  • reviewing a deal

At the same time shows simplified version of an approval process that waits for a human actor to provide review.

This example shows

  • exposing Submit Deal as public service
  • each process instance is going to be evaluated and asks for review
  • at any point in time service can be shutdown and when brought back it will keep the state of the instances

Note: The use of this example shows that the data sent to Infinispan is saved, you can shut down the application and restart it and as long as Infinispan is running after you restart you should still see the data

It utilizes Infinispan server as the backend store.

  • Process (submitDeal.bpmn)

  • Process Properties (top)

  • Process Properties (bottom)

  • Call a deal

  • Call a deal (Assignments)

  • Print review the Deal

  • Subprocess (reviewDeal.bpmn)

  • Deal Review (top)

  • Deal Review (bottom)

  • Review deal user task (top)

  • Review deal user task (bottom)

  • Review deal user task (Assignments)

Infrastructure requirements

This quickstart requires an Infinispan server to be available and by default expects it to be on default port and localhost.

You can install Infinispan server by downloading version 12.x from the official website.

  • Infinispan installed and running

Build and run

Prerequisites

You will need:

  • Java 11+ installed
  • Environment variable JAVA_HOME set accordingly
  • Maven 3.8.6+ installed

Compile and Run in Local Dev Mode

mvn clean compile spring-boot:run

Kogito runtimes need to be able to safely handle concurrent requests to shared instances such as process instances, tasks, etc. This feature is optional and can be pluggable with persistence using the following property and value to the src/main/resources/application.properties file.

kogito.persistence.optimistic.lock=true 

Additionally, you can build this project with -PpersistenceWithLock profile to run with persistence and lock on.

Package and Run using uberjar

mvn clean package

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

java -jar target/process-infinispan-persistence-springboot.jar

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.

Submit a deal

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

{
"name" : "my fancy deal",
"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 '{"name" : "my fancy deal", "traveller" : { "firstName" : "John", "lastName" : "Doe", "email" : "[email protected]", "nationality" : "American","address" : { "street" : "main street", "city" : "Boston", "zipCode" : "10005", "country" : "US" }}}' http://localhost:8080/deals

this will then trigger the review user task that you can work.

Get review task for given deal

First you can display all active reviews of deals

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

based on the response you can select one of the reviews to see more details

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

where uuid is the id of the deal review you want to work with.

Next you can get the details assigned to review user task by

curl -H 'Content-Type:application/json' -H 'Accept:application/json' http://localhost:8080/dealreviews/{uuid}/review/{tuuid}?user=john

where uuid is the id of the deal review and tuuid is the id of the user task you want to get

Complete review task for given deal

Last but not least you can complete review user task by

curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"review" : "very good work"}' http://localhost:8080/dealreviews/{uuid}/review/{tuuid}?user=john

where uuid is the id of the deal review and tuuid is the id of the user task you want to get

  • Review Log should look similar to
Review of the deal very good work for traveller Doe

Deploying with Kogito Operator

In the operator directory you'll find the custom resources needed to deploy this example on OpenShift with the Kogito Operator.