This project demonstrates a credit card application approval process using Quarkus and IBM Business Automation Manager Open Edition (BAMOE).
Ensure you have the following tools installed:
- Java 17 (developed with semeru-jdk-17.0.11+9)
- Maven CLI (developed with 3.9.8)
- Git CLI
- OC CLI
- Optional: Docker/Podman for faster Maven setup
- Optional: Quarkus CLI for a better experience
- Optional: OpenShift 4 (tested on 4.16.4) for testing OpenShift deployment
- VSCode IDE
To confirm the versions of these tools, you can run:
java -version
mvn --version
git --version
oc version
docker --version # or podman --version
quarkus --version
-
Install the Dev Tools VSCode extension.
-
Prepare the OpenShift environment (can be provisioned for free using Developer Sandbox for Red Hat OpenShift).
-
Set up the Maven repository:
-
Run the Maven repository container:
podman run -d -p 8585:80 --platform linux/amd64 --name mvn-repo910 quay.io/bamoe/maven-repository:9.1.0-ibm-0001
-
Add to
~/.m2/settings.xml
:<profile> <id>ibm-bamoe-910</id> <repositories> <repository> <id>ibm-bamoe-enterprise-maven-repository</id> <url>http://localhost:8585</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>ibm-bamoe-enterprise-maven-repository</id> <url>http://localhost:8585</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile>
-
Add to the active profiles section:
<activeProfile>ibm-bamoe-910</activeProfile>
-
Download
bamoe-9.1.0-maven-repository.zip
from the IBM Open Editions Developer Access Program. -
Unzip:
unzip bamoe-9.1.0-maven-repository.zip -d ~/.m2/bamoe-910
-
Configure
~/.m2/settings.xml
:<profile> <id>ibm-bamoe-enterprise-maven-repository</id> <repositories> <repository> <id>ibm-bamoe-enterprise-maven-repository</id> <url>file:///Users/your-username/.m2/bamoe-910/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>ibm-bamoe-enterprise-maven-repository</id> <url>file:///Users/your-username/.m2/bamoe-910/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile>
-
Activate the profile by adding this in the activeProfiles section:
<activeProfile>ibm-bamoe-enterprise-maven-repository</activeProfile>
-
Clone the project:
git clone https://github.com/kmacedovarela/demo-cc-application-approval
-
Open in VSCode:
code demo-cc-application-approval
-
Let's start by checking the process and decision files under the resource folders. The process describes the credit card approval process:
This diagram shows the overall flow of the credit card application process, including automatic and manual approval paths.
-
It includes an automated eligibility decision using DMN (Decision Model and Notation):
This DMN diagram represents the decision logic for determining applicant eligibility. It takes into account factors such as credit score, annual income, and age to calculate an eligibility score.
-
And for reference, this is how the score is calculated using a decision table:
-
The three main paths are: automatic approval, rejection, and manual approval. These are based on the outcome of the decision nodes.
-
The process includes custom Java code for generating CC details in the
org.acme.cc_approval.service.CreditCardService
class.
-
Ensure all dependencies are available:
mvn clean install
-
Start Quarkus in dev mode:
mvn quarkus:dev
or with Quarkus CLI:
quarkus dev
-
Press
d
to open Quarkus Dev UI in your browser. -
Locate the "jBPM Quarkus Dev UI" extension and click on "Process Instances" to see the process management console.
-
In the management console, click on the "Process Definition" tab and start a new process instance for "ccapplicationapproval" with the following data:
- Age: 50
- Annual income: 50000
- Credit score: 500
- Is student: false (unchecked)
- Name: Karina
-
Click on "Go to process details" and check the process information:
-
Open the task inbox on the left menu, and click on the user task:
Note: If no user task is there, it means you took more than 2 minutes (timer event duration). Change the filter to show aborted tasks, and you should see it as
Aborted
. -
Click on "Claim", open the task again, type "approved" in the approval field, and click "Complete":
-
Go back to the process instance details and check what happened:
- Navigate to http://localhost:8080/q/swagger-ui/#/ in your browser.
- Explore the APIs automatically generated based on the process and decisions.
In the Dev UI, locate "Kogito Data Index PostgreSQL Quarkus Add-On" to open the GraphQL UI.
Example queries:
List process instances:
{
ProcessInstances {
id
processId
processName
state
nodes {
name
type
enter
exit
}
}
}
List user tasks with all inputs/outputs:
{
UserTaskInstances {
name
priority
processId
processInstanceId
inputs
outputs
}
}
Query process instances and their variables:
{
ProcessInstances {
id
variables
}
}
Get all user task instances for a specific process ID:
{
UserTaskInstances(where: { processId: "your-process-id" }) {
id
name
state
}
}
Query active process instances:
{
ProcessInstances(where: { state: ACTIVE }) {
id
processId
state
}
}
- Build and run the application:
mvn clean package java -jar target/quarkus-app/quarkus-run.jar
-
Log in to OpenShift:
oc login --token=yourtoken --server=yourserver
-
Package and deploy on OpenShift:
mvn clean package -Dquarkus.openshift.deployment=true
-
To simplify, you can get the Swagger UI URL with:
echo "http://$(oc get route/cc-application-approval -o jsonpath='{.spec.host}')/q/swagger-ui"
-
Get the GraphQL URL:
echo "http://$(oc get route/cc-application-approval -o jsonpath='{.spec.host}')/graphql"
-
Deploy the management console:
oc run mgmt-console --image=quay.io/bamoe/management-console:9.1.0-ibm-0001 --env="RUNTIME_TOOLS_MANAGEMENT_CONSOLE_DATA_INDEX_ENDPOINT=<your-graphql-url>"
-
Expose the service:
oc expose pod mgmt-console --port=8080 --name=mgmt-console-service oc expose svc/mgmt-console-service echo "http://$(oc get route mgmt-console-service -o jsonpath='{.spec.host}')"
Certainly! I'll rewrite the Testing section of the guide using these commands and explain each step:
This section demonstrates how to test the credit card application approval process using curl commands. We'll go through starting a process, claiming a task, updating variables, and querying process details.
# Query the OpenShift route dynamically and store it in the "url" variable with "http://" prefix
export url="http://$(oc get route cc-application-approval --template='{{ .spec.host }}')"; echo "URL: $url"
First, we set the base URL for our API calls to simplify subsequent commands.
# Start a new process instance and store the process instance ID
export pid=$(curl -X POST "$url/ccapplicationapproval" -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"applicant": {"name": "John", "student": false, "annualIncome": 50000, "creditScore": 500, "age": 50}}' | grep -o '"id":"[^"]*"' | sed 's/"id":"//g' | sed 's/"//g'); echo "Process ID: $pid"
This command starts a new process instance with the given applicant data and stores the returned process ID in the pid
variable.
# Retrieve the task ID associated with the process instance
export tid=$(curl -X POST "$url/graphql" -H "Content-Type: application/json" -d "{\"query\":\"{ UserTaskInstances(where: { processInstanceId: { equal: \\\"$pid\\\" } }) { id name actualOwner potentialGroups processInstanceId }}\"}" | grep -o '"id":"[^"]*"' | head -n 1 | sed 's/"id":"//g' | sed 's/"//g'); echo "Task ID: $tid"
This GraphQL query retrieves the task ID associated with our process instance and stores it in the tid
variable.
# Claim the task (without moving the process forward)
curl -X POST "$url/ccapplicationapproval/$pid/reviewApplication/$tid/phases/claim?user=admin" -H 'accept: application/json' -H 'Content-Type: application/json'
This command claims the task for the 'admin' user, which is necessary before we can update or complete the task.
# Update a variable in the task (in this case, reject the application)
curl -X PUT "$url/ccapplicationapproval/$pid/reviewApplication/$tid?user=admin" -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"approval": "rejected"}'
Here, we update the task by setting the 'approval' variable to 'rejected'.
# Retrieve the completed task details (optional)
curl -X POST "$url/graphql" -H "Content-Type: application/json" -d "{\"query\":\"{ UserTaskInstances(where: { processInstanceId: { equal: \\\"$pid\\\" } }) { id name actualOwner potentialGroups processInstanceId }}\"}"
This optional step retrieves the details of the completed task using a GraphQL query.
# Query process instance details (optional)
curl -X POST "$url/graphql" -H "Content-Type: application/json" -d "{\"query\":\"{ ProcessInstances(where: { id: { equal: \\\"$pid\\\" } }) { id processId processName state start end variables } }\"}"