This is a sample project demonstrating how Drools can process CloudEvents, evaluating them against a set of rules expressed in a simple YAML format.
In order to implement your own business logic rewrite the file rules.drl.yaml
under the src/main/resources/org/drools/cloudevents
folder (or add any other file with .drl.yaml
extension in that folder) and update the provided integration test accordingly.
To start the rule service:
mvn clean compile quarkus:dev
To test the service, open a new terminal and run:
curl -v http://localhost:8080/drools/evaluate \
-H "Ce-Specversion: 1.0" \
-H "Ce-Type: fact.Measurement" \
-H "Ce-Source: io.cloudevents.examples/user" \
-H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f78" \
-H "Content-Type: application/json" \
-H "Ce-Subject: SUBJ-0001" \
-d '{"id":"color","val":"red"}'
You should get a response:
...
{"color":"red"}
- Start a private registry locally. For example, using https://hub.docker.com/_/registry
docker run -d -p 5000:5000 --name registry registry:2
For simplicity, the steps run the registry without any authentication. For production, you should secure the registry.
- Edit application.properties. For example:
quarkus.container-image.build=true
quarkus.container-image.push=false
quarkus.container-image.registry=localhost:5000
quarkus.container-image.insecure=true
quarkus.container-image.group=my-private-group
quarkus.container-image.name=drools-cloudevents
quarkus.container-image.tag=latest
drools.prototypes=allowed
You may change quarkus.container-image.group
and quarkus.container-image.name
as you like.
- Build and push the image
mvn clean package -Dquarkus.container-image.push=true
- Run the registered image
docker run -d -p 8080:8080 localhost:5000/my-private-group/drools-cloudevents:latest