A quickstart project that deals with traveller processing carried by rules. It illustrates how easy it is to make the Kogito processes and rules to work with Apache Kafka
This example shows
This quickstart requires an Apache Kafka to be available and by default expects it to be on default port and localhost.
https://kafka.apache.org/quickstart
You will need:
mvn clean compile spring-boot:run
mvn clean package
To run the generated native executable, generated in target/
, execute
java -jar target/process-kafka-quickstart-springboot.jar
You can take a look at the OpenAPI definition - automatically generated and included in this service - to determine all available operations exposed by this service. For easy readability you can visualize the OpenAPI definition file using a UI tool like for example available Swagger UI.
In addition, various clients to interact with this service can be easily generated using this OpenAPI definition.
To make use of this application it is as simple as putting a message on travellers
topic with following content
Execute in a separate terminal session
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic processedtravellers
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic travellers
Content (cloud event format)
{ "specversion": "0.3", "id": "21627e26-31eb-43e7-8343-92a696fd96b1", "source": "", "type": "travellers", "time": "2022-02-24T13:25:16+0000", "data": { "firstName" : "Jan", "lastName" : "Kowalski", "email" : "jan.kowalski@example.com", "nationality" : "Polish" } }
One liner
{"specversion": "0.3","id": "21627e26-31eb-43e7-8343-92a696fd96b1","source": "","type": "travellers", "time": "2022-02-24T13:25:16+0000","data": { "firstName" : "Jan", "lastName" : "Kowalski", "email" : "jan.kowalski@example.com", "nationality" : "Polish"}}
this will then trigger the successful processing of the traveller and put another message on processedtravellers
topic.
To take the other path of the process put following message on travellers
topic
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic travellers
With the following content (Cloud Event Format)
{ "specversion": "0.3", "id": "31627e26-31eb-43e7-8343-92a696fd96b1", "source": "", "type": "travellers", "time": "2022-02-24T13:25:16+0000", "data": { "firstName" : "John", "lastName" : "Doe", "email" : "john.doe@example.com", "nationality" : "American" } }
One Liner
{"specversion": "0.3","id": "31627e26-31eb-43e7-8343-92a696fd96b1","source": "","type": "travellers", "time": "2022-02-24T13:25:16+0000","data": { "firstName" : "John", "lastName" : "Doe", "email" : "john.doe@example.com", "nationality" : "American"}}
this will not result in message being send to processedtravelers
topic.
In the operator
directory you'll find the custom resources needed to deploy this example on OpenShift with the Kogito Operator.