Count the execution time rules on the requested time.

74 views
Skip to first unread message

Kishan Kumar

unread,
Nov 21, 2022, 12:24:59 AM11/21/22
to Kogito development mailing list
Hi Kogito Team,

I am using Kogito with the Quarkus application for DMN execution.
But I need to count how many rules will execute at one request.
There has the option to count the rules in DMN using kogito and quarkus applications.

Thanks & Best Regard,
Kishan

Matteo Mortari

unread,
Nov 21, 2022, 5:58:26 AM11/21/22
to kogito-de...@googlegroups.com
Hi Kishan,

you could consider using a DMNRuntimeListener to implement your requirements.


Hope this helps,
MM

--
You received this message because you are subscribed to the Google Groups "Kogito development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kogito-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kogito-development/0c46deeb-945a-42d8-aac7-7889d4b0cf42n%40googlegroups.com.


--

Kishan Kumar

unread,
Nov 21, 2022, 6:04:52 AM11/21/22
to Kogito development mailing list
Hi Matteo Mortari,

Thanks for replied me.

I want to know which method is the best way to rule the count.
1. afterEvaluateDecision
2. afterEvaluateDecisionTable

Please let me know.

Thanks & Best Regard,
Kishan

Matteo Mortari

unread,
Nov 21, 2022, 7:08:18 AM11/21/22
to kogito-de...@googlegroups.com
Hi Kishan,

not really sure what "rule" means in context of DMN, as there's only decisions.

If you are interested in how many rows in a decision table has been selected Vs picked, then the listener method for the decision table is indeed most appropriate.

Hope this helps!
MM

Kishan Kumar

unread,
Nov 21, 2022, 7:17:56 AM11/21/22
to Kogito development mailing list
Hi Matteo,

I am looking for the decision rows in a decision table execution time and how many rows are selected.
Thanks & Regards,
Kishan 

Matteo Mortari

unread,
Nov 21, 2022, 7:20:02 AM11/21/22
to kogito-de...@googlegroups.com
Then indeed the method afterEvaluateDecisionTable can be used to understand which rows have been Selected Vs Picked
and the analogous beforeEvaluateDecisionTable for the start time

Hope this helps!
MM

Kishan Kumar

unread,
Nov 22, 2022, 1:37:31 AM11/22/22
to Kogito development mailing list
Hey  Matteo Mortari,

I am confused about the evaluation status and how to call the decision table and how to select the rows in afterEvaluateDecisionTable method.

Please can you help me to understand?
Thanks
Kishan

Matteo Mortari

unread,
Nov 22, 2022, 5:00:14 AM11/22/22
to kogito-de...@googlegroups.com
Hi Kishan,
can you provide a small, self-contained reproducer of the problem you are allegedly experiencing, please?
If you could share a sample DMN with the decision table, and with the Listener you implemented so far, I would happily take a look!

If instead you need tailored consulting services for writing a full-blown implementation specific to your needs and requirements from scratch, I suggest you get in touch with IBM, as they sell consulting engagements.

Let us know!
Hope this helps,
MM

Kishan Kumar

unread,
Dec 12, 2022, 2:26:45 AM12/12/22
to Kogito development mailing list
Hey  Matteo Mortari,

I want to know every decision table and how many rows are selected for the final outcome in DMN.

I have attached a Screenshot.
Let me know if is it correct way ya wrong.
Thanks
Kishan
Screenshot 2022-12-12 125601.png

Matteo Mortari

unread,
Dec 12, 2022, 2:34:08 AM12/12/22
to kogito-de...@googlegroups.com
Hi Kishan,

> I want to know every decision table and

given a DMNModel, you can retrieve all the Decision Table elements with something ~like:
dmnModel.getDefinitions().findAllChildren(DecisionTable.class)
> and how many rows are selected for the final outcome in DMN

for each AfterEvaluateDecisionTableEvent,
you can use methods getMatched() and getSelected() to know:
  • how many rows have matched and
  • how many ultimately selected by applying the decision table hit policy
Hope this helps,
MM

Kishan Kumar

unread,
Dec 12, 2022, 3:47:22 AM12/12/22
to Kogito development mailing list
Hey Matteo Mortari,

Do you have any examples?
regarding this implication.

Thanks 
Kishan 

Kishan Kumar

unread,
Dec 12, 2022, 5:08:23 AM12/12/22
to Kogito development mailing list
Hey Matteo Mortari,

I had implemented the getSelected() and getMatches() methods but I have doubts about both method.
any document about this method.

Thanks
Kishan

Matteo Mortari

unread,
Dec 12, 2022, 8:27:15 AM12/12/22
to kogito-de...@googlegroups.com
Hi Kishan,
I might consider writing an ad-hoc example, but I would prefer first to wrap up on DROOLS-7256 as that would benefit for this use case.

Will keep posted.

Hope this helps,
MM

Matteo Mortari

unread,
Dec 23, 2022, 4:12:19 AM12/23/22
to kogito-de...@googlegroups.com
As promised, I've implemented a Kogito example: KOGITO-8391 Pull Request
as 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.

I always advise to make the listener's callback method code as small as possible.
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

Kishan Kumar

unread,
Dec 23, 2022, 4:28:14 AM12/23/22
to Kogito development mailing list
Hey  Matteo Mortari,
Thanks for creating the one example for the Decision table count.


Thanks 
Kishan Kumar.

Reply all
Reply to author
Forward
0 new messages