This guide quickly explains how to getting started with Kogito Serverless Workflows in your local machine
To edit your workflows:
- Visual Studio Code with Red Hat Java Plugin installed
- Serverless Workflow Editor
To create the project skeleton, run:
quarkus create app -x=kogito-quarkus-serverless-workflow,quarkus-container-image-jib,quarkus-resteasy-jackson,quarkus-smallrye-openapi org.acme:my-first-ksw:1.0
The org.acme:my-first-ksw:1.0
is the group id, artifact id, and version of your project.
This command will create a Maven Quarkus project in the my-first-ksw
directory with all required Kogito dependencies.
Next, to make sure everything is working fine, try to compile the project with:
quarkus build
Go to the directory src/main/resources
and take a look at greetings.sw.yaml
.
You can play around and type the workflow definition by hand using the editor intellisense feature or using the text editor of your choice
Then run quarkus dev
from the project's root to start the Quarkus console.
To interact with the application, we have a couple of options described in the sections below.
Point your browser to the http://localhost:8080/q/swagger-ui/ address.
You should see a POST endpoint definition for this workflow named Greetings
. Click on the POST entry and in the button "Try it".
Copy and paste the following content:
{
"workflowdata": {
"name" : "John",
"language": "English"
}
}
Click on "Execute" and you should see a response similarly to this one:
{
"id": "c758eb9d-6242-4bda-a5f5-7f5d302943c0",
"workflowdata": {
"name": "John",
"language": "English",
"greeting": "Hello from YAML Workflow, ",
"finalGreeting": "Hello from YAML Workflow, John"
}
}
You can use an one line curl
:
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"workflowdata" : {"name": "John", "language": "English"}}' http://localhost:8080/greetings
You can use the Quarkus CLI to build your image with the following command:
quarkus build -Dquarkus.container-image.build=true
After building the image, you can start the container running:
docker run --rm -it -p8080:8080 <username>/my-first-ksw:1.0
You can then interact with the application the same way you did before in the previous sections.