This example contains a simple workflow service that illustrates callback state using OpenAPI callbacks functionality. A callback is a state that invokes an action and wait for an event (event that will be eventually fired by the external service notified by the action). This example consists of a callback state that waits for an event to arrive at the wait channel. Its action calls an external service that publishes the wait event over HTTP. After consuming the wait event, the workflow prints the message received in the wait event and ends the workflow.
To go further on using HTTP with Reactive Messaging, take a look at this article.
For information related to Open API callbacks functionality, please refer this document.
The service is described using JSON format as defined in the CNCF Serverless Workflow specification.
You will need:
Run the following commands from the callback-workflow directory as per the selected mode of running.
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-compensation-quarkus-{version}-runner
In another terminal, run the callback event service using the below command
mvn clean package quarkus:dev -Dquarkus.http.port=8181
The service based on the JSON workflow definition can be accessed by sending a request to http://localhost:8080/callback with the following content
{ "message": "Hello" }
Complete curl command can be found below:
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"message": "Hello"}' http://localhost:8080/callback
Should return something like this (“id” will change):
{ "id":"f9a75f77-7269-4b18-93cd-2955e3406cd4", "workflowdata":{ "message":"New Event" } }