This example contains a simple workflow service that illustrate foreach state usage. ForEach
is a state that invokes an action over any item of an input collection. This example consist of just one foreach
state. A list of int
is passed and every item increase its value one unit. Another action prints the updated value. The service is described using JSON format as defined in the CNCF Serverless Workflow specification.
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-foeach-quarkus-{version}-runner
The service based on the JSON workflow definition can be access by sending a request to http://localhost:8080/foreach
Complete curl command can be found below:
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"input": [1,2,3]}' http://localhost:8080/foreach
once completed, it should return:
{ "workflowdata": { "output": [ 2, 3, 4 ] } }