This project contains a workflow and some auxiliary resources that implement the Currency Exchange Workflow described in the SonataFlow guide: Orchestration of third-party services using OAuth 2.0 authentication.
The service is described using JSON format as defined in the CNCF Serverless Workflow specification.
This example requires a Keycloak server to be running, and expects it to be listening on the port 8281 and localhost.
In a new terminal, go to the serverless-workflow-oauth2-orchestration-quarkus/scripts
directory and execute:
$ cd serverless-workflow-oauth2-orchestration-quarkus/scripts $ ./startKeycloak.sh
Alternatively, you can use docker-compose following this procedure:
$ cd serverless-workflow-oauth2-orchestration-quarkus/docker-compose $ docker-compose up
In this way, a container for Keycloak will be started on port 8281. You can navigate to this URL Keycloak console to check that the server is running.
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/currency-exchange-workflow-{version}-runner
The service based on the JSON workflow definition can be accessed by sending requests to the http://localhost:8080/currency-exchange-workflow url.
Use the following curl command to create a new workflow instance and get the results:
curl -X 'POST' \ 'http://localhost:8080/currency_exchange_workflow' \ -H 'accept: */*' \ -H 'Content-Type: application/json' \ -d '{ "currencyFrom": "EUR", "currencyTo": "USD", "exchangeDate": "2022-06-10", "amount": 2.0 }'