The workflow is described using JSON format as defined in the CNCF Serverless Workflow specification.
The workflow expects a JSON input containing the temperature in Fahrenheits:
{ "fahrenheit": 100 }
The workflow starts defining the constants to be used during the computation. Then it will call a sequence of REST functions to solve the equation: Celsius = (Fahrenheit - 32) * 0.5553
. Finally, the result will be returned to the caller, the final product of the equation is the temperature converted to Celsius.
You will need:
JAVA_HOME
set accordinglyWhen using native image compilation, you will also need:
GRAALVM_HOME
set accordinglymvn 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/conversion-workflow-runner
Before submitting a request, run the Subtraction and Multiplication on separate terminals on ports 8181
and 8282
respectively (use the property quarkus.http.port
).
The service based on the JSON workflow definition can be access by sending a POST request to http://localhost:8080/fahrenheit_to_celsius with the following content:
{ "workflowdata": { "fahrenheit": 100 } }
Complete curl command can be found below:
curl -X POST \ -H 'Content-Type:application/json' \ -H 'Accept:application/json' \ -d '{"fahrenheit": 100}' \ http://localhost:8080/fahrenheit_to_celsius | jq .
You should have a reply similar to this one:
{ "id": "2287167f-1392-480e-8e20-6acd5922dfac", "workflowdata": { "fahrenheit": 100, "subtractValue": "32.0", "multiplyValue": "0.5556", "difference": 68.0, "product": 37.7808 } } }
In the operator
directory you'll find the custom resources needed to deploy this example on OpenShift with the Kogito Operator.