A quickstart project that processes deals for travellers. It utilizes process composition to split the work of
At the same time shows a simplified version of an approval process that waits for a human actor to provide a review.
This example shows:
Note: The use of this example shows that the data sent to PostgreSQL is saved. You can shut down the application and restart it, and as long as PostgreSQL is running after you restart you should still see the data.
It utilizes PostgreSQL server as the backend store.
This quickstart requires a PostgreSQL server to be available with a database, a user and credentials already created , these configurations should then be set in the connection URI parameter in applications.properties file with the key kogito.persistence.postgresql.connection.uri
, i.e postgresql.connection.uri=postgresql://kogito-user:kogito-pass@localhost:5432/kogito
here are the full settings for URI
You must set the property kogito.persistence.type=postgresql
to enable PostgreSQL persistence. There is also a configuration to allow the application to run DDL scripts during the initialization, which you can enable with the property kogito.persistence.auto.ddl=true
. For more details you can check applications.properties.
Optionally and for convenience, a docker-compose configuration file is provided in the path docker-compose/, where you can just run the command from there:
docker-compose up
In this way a container for PostgreSQL running on port 5432, along with PgAdmin, running on port 8055 to allow the database management.
The default admin user for PostgreSQL is postgres
with password pass
, for PgAdmin the default user created is user@user.org
with password pass
, the database connection could be set in PgAdmin using the hostname postgres-container
for the PostgreSQL server, details defined in configuration file, an initializer script is executed to create the kogito
database and kogito-user
.
You will need:
mvn clean package spring-boot:run
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.
mvn clean package
To run the generated native executable, generated in target/
, execute
java -jar target/process-postgresql-persistence-springboot.jar
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.
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" : "jon.doe@example.com", "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" : "jon.doe@example.com", "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 with.
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
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 of the deal very good work for traveller Doe