This example shows how to enable storing Kogito process data and events to MongoDB.
By doing so, it allows demonstrating how to use the transactional outbox pattern with Debezium, which then reads these events and publishes to Kafka.
mvn clean package -Dcontainer
docker compose up
RUNNING
statecurl http://localhost:8083/connectors/kogito-connector/status
curl -d '{"approver" : "john", "order" : {"orderNumber" : "12345", "shipped" : false}}' -H "Content-Type: application/json" -X POST http://localhost:8080/orders
http://localhost:9000/
With the Kafka broker info from step 8, run the Kogito Data Index Service with MongoDB to consume Kafka messages: https://github.com/apache/incubator-kie-kogito-runtimes/wiki/Data-Index-Service
Shut down the cluster
docker compose down
Once the service is up and running, you can use the following examples to interact with the service.
Allows to create a new order with the given data:
curl -d '{"approver" : "john", "order" : {"orderNumber" : "12345", "shipped" : false}}' -H "Content-Type: application/json" -X POST http://localhost:8080/orders
or on windows
curl -d "{\"approver\" : \"john\", \"order\" : {\"orderNumber\" : \"12345\", \"shipped\" : false}}" -H "Content-Type: application/json" -X POST http://localhost:8080/orders
As response the updated order is returned.
Returns list of orders currently active:
curl -X GET http://localhost:8080/orders
As response an array of orders is returned.
Returns order with given id (if active):
curl -X GET http://localhost:8080/orders/1
As response a single order is returned if found, otherwise 404 Not Found is returned.
Cancels order with given id
curl -X DELETE http://localhost:8080/orders/1
Getting order items sub processes
curl -X GET http://localhost:8080/orderItems
Example response:
[ { "id":"66c11e3e-c211-4cee-9a07-848b5e861bc5", "order": { "orderNumber":"12345", "shipped":false, "total":0.537941914075738 } } ]
Getting user tasks awaiting user action
curl -X GET http://localhost:8080/orderItems/66c11e3e-c211-4cee-9a07-848b5e861bc5/tasks?user=john
Example response:
[ {"id":"62f1c985-d31c-4ead-9906-2fe8d05937f0","name":"Verify order"} ]
Getting user task details
curl -X GET http://localhost:8080/orderItems/66c11e3e-c211-4cee-9a07-848b5e861bc5/Verify_order/62f1c985-d31c-4ead-9906-2fe8d05937f0?user=john
Example response:
{ "id":"62f1c985-d31c-4ead-9906-2fe8d05937f0", "input1": { "orderNumber":"12345", "shipped":false, "total":0.537941914075738 }, "name":"Verify order" }
Complete user task
curl -d '{}' -H "Content-Type: application/json" -X POST http://localhost:8080/orderItems/66c11e3e-c211-4cee-9a07-848b5e861bc5/Verify_order/62f1c985-d31c-4ead-9906-2fe8d05937f0?user=john
As response the updated order is returned.
Example response:
{ "id":"66c11e3e-c211-4cee-9a07-848b5e861bc5", "order": { "orderNumber":"12345", "shipped":false, "total":0.537941914075738 } }
Outbox pattern: https://microservices.io/patterns/data/transactional-outbox.html
Debezium Connector: https://debezium.io/blog/2019/02/19/reliable-microservices-data-exchange-with-the-outbox-pattern/
debezium-examples: https://github.com/debezium/debezium-examples/blob/main/tutorial/README.md#using-mongodb
debezium-images: https://github.com/debezium/docker-images/tree/main/examples/mongodb/