This project contains a simple serverless workflow and some auxiliary resources that implement the Query and Answer Service described in the serverless-workflow-qas-service-showcase/README.md. Please read it before to continue.
The service is described using JSON format as defined in the CNCF Serverless Workflow specification.
This quickstart requires an Apache Kafka to be available and, by default, expects it to be on the default port and localhost.
https://kafka.apache.org/quickstart
The topic “query_response_events” is used to publish and consume the events.
Optionally and for convenience, a docker-compose configuration file is provided in the path ../docker-compose, where you can just run the command from there:
docker-compose up
In this way, a container for Kafka will be started on port 9092.
Alternatively, you can run this example using persistence with a PostgreSQL server.
Configuration for setting up the connection can be found in applications.properties file, which follows the Quarkus JDBC settings, for more information please check JDBC Configuration Reference.
Optionally and for convenience, a docker-compose configuration file is provided in the path ../docker-compose, where you can just run the command from there:
docker-compose up
In this way, a container for PostgreSQL will be started on port 5432.
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
To enable persistence, please append -Ppersistence
to your Maven command. That will ensure the correct dependencies are in place, and automatically set the required properties to connect with the PostgreSQL instance from the provided docker compose.
mvn clean package -Ppersistence
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/query-answer-service-{version}-runner
The service based on the JSON workflow definition can be accessed by sending requests to the http://localhost:8080/qaservice url.
Use the following curl command to list all the active serverless workflow instances:
curl -X 'GET' 'http://localhost:8080/qaservice' -H 'accept: application/json'
Use the following curl command to create a new serverless workflow instance:
curl -X 'POST' 'http://localhost:8080/qaservice' -H 'accept: application/json' -H 'Content-Type: application/json' \ -d '{ "query" : "the text for my query" }'
Use the following curl command to list the knowledge database:
curl -X 'GET' 'http://localhost:8080/queries' -H 'accept: application/json'
The swagger is also available in the following url: http://localhost:8080/q/swagger-ui