The workflow is described using JSON format as defined in the CNCF Serverless Workflow specification.
The workflow expects a JSON input containing a collections of numbers.
The workflow starts invoking a GET to obtain a random integer. This integer is passed together with the list of numbers to a second REST invocation, a POST, which multiply each element of the array by the generated number and returns the sum. Finally, the resulting integer is printed using sysout script.
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/sw-quarkus-greeting-{version}-runner
The service based on the JSON workflow definition can be access by sending a request to http://localhost:8080/RESTExample' with following content
{ "inputNumbers": [ 1, 2, 3, 4, 5, 6, 7, 8, 7 ] }
Complete curl command can be found below:
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"inputNumbers": [1,2,3,4,5,6,7,8,7]}' http://localhost:8080/RestExample
Log after curl executed:
{ "inputNumbers": [ 1, 2, 3, 4, 5, 6, 7, 8, 7 ] }
In Quarkus you should see the log message printed:
The sum is: 387