Skip to content

Latest commit

 

History

History
 
 

serverless-workflow-events-quarkus

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Kogito Serverless Workflow - Job Application Events Example

Description

This example showcases the use of Serverless Workflow specification markup to create a job application decision workflow. It also showcases the power of Kogito to create a completely event-driven services example. The UI and workflow service communicate only over events (CloudEvents format) that are streamed to Kafka topics.

Here is the overall architecture of this example:

Example Architecture

Installing and Running

Prerequisites

You will need:

  • Java 11+ installed
  • Environment variable JAVA_HOME set accordingly
  • Maven 3.8.6+ installed
  • Apache Kafka installed

When using native image compilation, you will also need:

  • GraalVm 19.3.1+ installed
  • Environment variable GRAALVM_HOME set accordingly
  • Note that GraalVM native image compilation typically requires other packages (glibc-devel, zlib-devel and gcc) to be installed too. You also need 'native-image' installed in GraalVM (using 'gu install native-image'). Please refer to GraalVM installation documentation for more details.

Infrastructure requirements

This quickstart requires Apache Kafka to be available and by default expects it to be on default port and localhost.

  • Install and Startup Kafka Server / Zookeeper

https://kafka.apache.org/quickstart

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.

Compile and Run in Local Dev Mode

mvn clean compile quarkus:dev

Package and Run in JVM mode

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

Package and Run using Local Native Image

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-events-quarkus-runner

Running the Example

After starting the example application you can access the front-end page at:

http://localhost:8080/

You should see the following page:

Example1

Fill in the "Submit New Applicant" form and submit it. This will send a cloud event to Kafka which starts a new workflow instance. The workflow includes a rule function call which evaluates the salary entered. Before the workflow execution ends it sends a cloud event to Kafka. The UI subscribes to these events using SSE and updates the "Application Decision" table with the results, for example:

Example2