I forgot to give the priority of the booking rules in my example, here it is :
- BR1 : low priority (1
- BR2 : higher priority (2)
- BR3 : same as BR2
Sorry
Joel
________________________________
De : rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] De
la part de Costigliola Joel (EXT)
Envoyé : mercredi 28 octobre 2009 14:57
À : 'Rules Users List'
Objet : [rules-users] Specific Agenda strategy to control which rules to fire
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
________________________________
Ce courriel et toutes les pièces jointes sont confidentiels et peuvent être couverts par
un privilège ou une protection légale. Il est établi à l'attention exclusive de ses
destinataires. Toute utilisation de ce courriel non conforme à sa destination, toute
diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation
expresse préalable. Toutes opinions exprimées dans ce courriel ne sauraient nécessairement
refléter celle de Natixis, de ses filiales. Elles sont aussi susceptibles de modification
sans notification préalable. Si vous recevez ce courriel par erreur, merci de le détruire
et d'en avertir immédiatement l'expéditeur. L'Internet ne permettant pas
d'assurer l'intégrité de ce courriel, Natixis décline toute responsabilité
s'il a été altéré, déformé ou falsifié et chaque destinataire qui utilise ce mode de
communication est supposé en accepter les risques.
This email and any attachment are confidential and may be legally privileged or otherwise
protected from disclosure. It is intended only for the stated addressee(s) and access to
it by any other person(s) is unauthorised. Any use, dissemination or disclosure not in
accordance with its purpose, either in whole or in part, is prohibited without our prior
formal approval. Any opinion expressed in this email may not necessarily reflect the
opinion of Natixis, its affiliates. It may also be subject to change without prior notice.
If you are not an addressee, you must not disclose, copy, circulate or in any other way
use or rely on the information contained in this email. If you have received it in error,
please inform us immediately and delete all copies. The Internet can not guarantee the
integrity of this email therefore Natixis shall not be liable for the email if altered,
changed or falsified and anyone who communicates with us by e-mail is taken to accept
these risks.
________________________________
--------------------------------------------------------
Ce courriel et toutes les pièces jointes sont confidentiels et peuvent être couverts par
un privilège ou une protection légale. Il est établi à l'attention exclusive de ses
destinataires. Toute utilisation de ce courriel non conforme à sa destination, toute
diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation
expresse préalable. Toutes opinions exprimées dans ce courriel ne sauraient nécessairement
refléter celle de Natixis, de ses filiales. Elles sont aussi susceptibles de modification
sans notification préalable. Si vous recevez ce courriel par erreur, merci de le détruire
et d'en avertir immédiatement l'expéditeur. L'Internet ne permettant pas
d'assurer l'intégrité de ce courriel, Natixis décline toute responsabilité
s'il a été altéré, déformé ou falsifié et chaque destinataire qui utilise ce mode de
communication est supposé en accepter les risques.
This email and any attachment are confidential and may be legally privileged or otherwise
protected from disclosure. It is intended only for the stated addressee(s) and access to
it by any other person(s) is unauthorised. Any use, dissemination or disclosure not in
accordance with its purpose, either in whole or in part, is prohibited without our prior
formal approval. Any opinion expressed in this email may not necessarily reflect the
opinion of Natixis, its affiliates. It may also be subject to change without prior notice.
If you are not an addressee, you must not disclose, copy, circulate or in any other way
use or rely on the information contained in this email. If you have received it in error,
please inform us immediately and delete all copies. The Internet can not guarantee the
integrity of this email therefore Natixis shall not be liable for the email if altered,
changed or falsified and anyone who communicates with us by e-mail is taken to accept
these risks.
--------------------------------------------------------