Hello all,
I need some help to to set a specific Agenda
strategy in order to control finely which activated rules will be fired.
Problem context :
-----------------
My company is a bank where traders are making deals
on markets, these deals must be classified in book, this is what we call
“booking process”.
Booking is done according to booking criteria :
which trader has made the deal ? on which product ? wich market ? etc …
A booking rule defines a set of criteria and the
target book where the deal will classified, it also has a priority, note that
it is ok that two booking rule have same priority.
I want to implement booking rule as Drools rule.
Several booking rule can be applied to a deal, in
that case choosing the right booking rule to fire depends on the following
algorithm :
- look all the activated booking rule of the
highest priority,
--- if there is a unique rule apply it
--- if there is no unique rule (0 rule or more than
one), look at rules of a lesser priority and apply the same logic.
Next section is an example that will clear things
(I hope).
Example :
---------
A deal D1 has been done by Alex on NY market to buy
Google stocks.
We have 3 booking rules :
- BR1 : criteria = trader=Alex / book = B1
- BR2 : criteria = trader=Alex and product = google
stock / book = B2
As BR2 is more precise than BR1, il will matches
the deal and book it in B1
If the deal was on another product, BR1 would have
been applied.
Things gets more complicated when 2 rules of same
priority can be applied.
Let's imagine we add the following booking rule
- BR3 : criteria = trader=Alex and market = NY /
book = B3
We have a problem to book D1 since BR2 and BR3 can
be applied but have same priority.
We can't choose one over the other thus we must
apply a less precise/prioritary rule (if unique at its own precision level).
In my example, that would lead to apply BR1.
Question :
----------
If I define BR1,BR2,BR3 as Drools rules, how can I
tell Drools :
- to execute a rule only if there is no other
active rule with same precision that could be applied ?
- to look for a unique matching rule with less
precision level ?
I think it's the Agenda responsibility to take this
decision, but I don't know how implement that.
Can you give some advices on that ?
Thanks for your lights in advance,
Regards,
Joel