'Integration between kafka and drools

I'm designing a system that needs:

  • to consume events published using kafka,
  • to apply on them some rules using a rule based engine
  • to publish on kafka some events when the rules are matched.

To do a simple example (the real use cases are more complex): the system receives events from a temperature sensor, it uses drools to apply some rules on these events - i.e., a decision table with thresholds - and then it sends a suggestion on kafka, indicating "close the window", when the temperature goes beyond the threshold.

For what I have understood, reading the Drools documentation, currently my idea for developing this application is the following:

  • Develop a Drools project inserting the rules to be applied using .drl.
  • Configure Drools to work in Stream mode.
  • Insert in the application also a kafka consumer, which consumes the events pubblished and then insert in drools a new event, every time it is received from kafka.
  • Insert in the application a rules listener that is called every time a rule is executed.
  • Publish an event on kafka every time the listener receives the events.

Is this a right way to proceed or is there another "standard" way to do this integration between kafka and drools?



Solution 1:[1]

You might consider using Quarkus, Camel and Kogito applying very similar blueprint and solution as demonstrated in:

The difference to compared to your use case, specifically:

To do a simple example (the real use cases are more complex): the system receives events from a temperature sensor, it uses drools to apply some rules on these events - i.e., a decision table with thresholds - and then it sends a suggestion on kafka, indicating "close the window", when the temperature goes beyond the threshold.

(emphasis mine) is that the resources above are using DMN for a decision table, but you might as well implement the same with Drools' DRL.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tarilabs