As promised, I've implemented a Kogito example:
KOGITO-8391 Pull Requestas my humble gift to the Drools and Kogito community 🎁 given the festive period in many parts of the world :)
I would expect this
Kogito example to be available starting with Kogito 1.33 etc.
I would like to spend a few words commenting on this example, which is intended to cover for the most salient parts while considering wiring up a DMN Listener.
The callback method code is a 1 statement, so is very short. Please notice the callback method call does not implement any logic or event processing.
In this case the "event buffer" uses a
concurrent collection to make it consumable asynchronously (more on that later).
Later in this example the buffer is inspected asynchronously in read-only mode, and another asynchronous thread will periodically clear the buffer as a whole.
In an alternative implementation, one may inspect the buffer to consume the event at-once, via poll(), or changing the underlying implementation to drain the buffer to another collection variable.
This method is annotated with Quarkus based capabilities so that this method will be called asynchronously from another thread.
In an alternative implementation, one may use other framework async capabilities, or directly use JDK-provided thread pools or analogous, to have the method be called asynchronously.
This one-liner, identifies the original DecisionTable linked to the event; the resulting DecisionTable pojo is a class representing the table as coming from the xml, as deserialized.
This statement inspects the event in more detail, and we have in scope also the original DecisionTable from the xml.
- display how many rows/rules the original table from xml has defined in the model
- display the row numbers of the actual rows which matched (evaluated to matching)
- display the row numbers that the hit policy of that table finally considered, from the set of the matching one.
In an alternative implementation, one may collect these metrics as needed.
To keep this example simple, this asynchronous method assumes there is only 1 DMN model and its coordinates,
here.
In an alternative implementation, one may consider cycling over all DMNModels; for a Kogito based on Quarkus application, such as this example, one may implement that
as suggested here.
Please notice this email is intended with hyperlinks to github permalinks.
Hope this helps,
Ciao!
MM