This example contains a simple workflow service that use DMN. The services are described using JSON format as defined in the CNCF Serverless Workflow specification.
The workflow expects as JSON input containing driver details and a traffic violation (see details in the Submit a request section).
The workflow uses that input to execute a decision file which evaluates if the driver should be suspended or not.
You will need:
When using native image compilation, you will also need:
mvn clean package quarkus:dev
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
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/serverless-workflow-dmn-quarkus-{version}-runner
Once the service is up and running, you can use the following example to interact with the service.
Returns penalty information from the given inputs -- driver and violation:
Given inputs:
{ "Driver":{"Points":2}, "Violation":{ "Type":"speed", "Actual Speed":120, "Speed Limit":100 } }
Curl command (using the JSON object above):
curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"Driver":{"Points":2},"Violation":{"Type":"speed","Actual Speed":120,"Speed Limit":100}}' http://localhost:8080/traffic-violation
or on Windows:
curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d "{\"Driver\":{\"Points\":2},\"Violation\":{\"Type\":\"speed\",\"Actual Speed\":120,\"Speed Limit\":100}}" http://localhost:8080/traffic-violation
As response, penalty information is returned.
Example response:
{"workflowdata": { "Violation":{ "Type":"speed", "Speed Limit":100, "Actual Speed":120 }, "Driver":{ "Points":2 }, "Fine":{ "Points":3, "Amount":500 }, "Should the driver be suspended?":"No" } }