How many KnowledgeBases?
by Laird Nelson
Forgive me for what I suspect is an elementary question. That said, I did
not see it explained in newcomer-friendly language in the documentation, if
at all. And I'm a newcomer!
I'm working on a system for--among other things--pricing things. Drools
Expert is a great fit for this.
The system also has to do other things that have nothing to do with pricing
(let's say shipping, to keep it simple). There are places where Drools
Expert is a great fit for this as well.
In both cases, let's assume I might insert a given product into the engine,
turn the crank, and collect my results. But the kinds of results I'm
looking for--and the kinds of calculations I would expect to be
performed--are quite different in each case.
So, let's assume that--naively speaking here--when I insert the product and
{handwave handwave} I "know" I'm doing pricing work, then I only need
pricing-related rules to fire (I don't need the, say,
product-color-determining rules to fire, or the
can-the-product-be-shipped-to-Abu-Dhabi rules to fire, or the
how-many-people-liked-this-product rules to fire, etc.).
And when I insert the product and {handwave handwave} I "know" I'm
doing--whatever--shipping work, then I don't need the pricing rules to even
be considered.
I found this (http://n3.nabble.com/Grouping-rules-td55531.html#a55531) as
perhaps one way of creating different sets of rules to be evaluated in
different contexts. This smelled very arcane to me for this purpose,
but...? perhaps it's the way to go?
Another is obviously to create *n* KnowledgeBases, each with its own set of
rules, where *n* is the number of contexts or activities or types of
activities that I'm performing. Then I'd look up the (pre-created)
KnowledgeBase
appropriate for the particular calculation I need performed. That seems
like solving the problem with a crowbar, a length of iron pipe and a
blowtorch. Ick.
Is there an accepted/preferred way to handle this sort of thing?
Agenda-groups seem...well, perhaps they'd work, but it seems awfully arcane
for something that I was hoping would be a little more end-user friendly.
Quoting the Expert manual:
When Should You Use A Rule Engine?
> [...]
> Domain experts often possess a wealth of knowledge about business rules and
> processes. They typically are nontechnical, but can be very logical. Rules
> can allow them to express the logic in their own terms. Of course, they
> still have to think critically and be capable of logical thinking.
>
My domain users would almost certainly not think in terms of agenda groups.
Perhaps I could hide this in a DSL or something, but it seems to me there
must be some facility built into Drools for separating collections of rules
into channels, or groups, or partitions, or.... Is there?
Best,
Laird
16 years, 4 months
Proper order for resource scanners and notifiers?
by ljnelson
Another newcomer question.
I have studied the javadocs, such as they are, for KnowledgeAgentFactory.
It seems to suggest, though not explicitly state, that one should invoke
some combination of ResourceChangeNotifier and ResourceChangeScanner to
cause the KnowledgeAgent to become aware of new rule bases.
Then it says that both services must be started, even though both services
are presumably not aware of each other.
And none of the sample code actually seems to hook the notifier up to the
scanner.
Then, it also looks like the KnowledgeAgent (Impl) itself wires these two
things up. But it seems to do it backwards (to my way of thinking): the
scanner is added to the notifier?
Somewhere around here is where my eyes start to glaze over. :-D
What is the proper sequence for setting up a knowledge agent so that the
file system is scanned, say, every 30 seconds? The KnowledgeAgentFactory
documentation looks like it *wants* to explain this, but doesn't get all the
way there.
Just want to make sure I'm doing everything right.
Thanks,
Laird
--
View this message in context: http://n3.nabble.com/Proper-order-for-resource-scanners-and-notifiers-tp2...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years, 4 months
Disable rules at runtime to make sure they get executed only once
by Malinda Kaushalye
Hi All,
I need to write a set of rules that each get executed only ONCE. However, the conditions are met at different stage of execution as events are coming thru a stream. Therefore I need to disable each rule at different stages.
I was looking for some mechanism to disable a rule after it gets executed. Something like this.
rule "myExecuteOnlyOnceRule"
when
//some condition tat evaluate events
then
this.rule.disable() / disable(drools.getRule())
end
Let me know if you know such a function or a workaround for this issue.
Cheers,
Malinda
16 years, 4 months
Log messages are in not in the expected order
by Malinda Kaushalye
Hi All,
Im writing an event driven application where I need to log
1. When a particular event get triggered.
2. When a particular event pattern (condition) is matched.
Events are fired both in the Java code as well as within the drools rule RHS.
Event patterns are matched in the drools LHS.
The issue is the logged message of firing an event is recorded after the LHS evaluation is matched. This happens when the event is fired within the Java code.
e.g. Let's assume there is a precondition (e1 && e2) of a rule. The event e1 is fired by the Java code and event e2 is fired by the RHS of a rule.
In that case the record sequence is
- e2 fired
- (e1 & e2) evaluated
- e1 fired.
The above seems wrong isn't it? It should be
- e1 fired
- e2 fired
- (e1 & e2) evaluated
I use log4j for logging. But this is the case even when I tried System.out.println
Any clue?
Cheers,
Malinda
16 years, 4 months
Rule in decision table
by Jeffrey Schneller
I am trying to write a condition for a decision table and can't seem to
figure out how to do it.
I have a global variable called area. This is in sq. ft.
I have a fact called Item which has an attribute called weight. This is
in grams / sq. ft.
The Item comes from the attribute called value from a fact named Choice
where the sku attribute matches what is in the rule
I want to compare the (weight * area) to the parameter for the row. The
parameter is being passed in as lbs.
Here is what I tried for my three condition columns:
CONDITION
CONDITION
CONDITION
mm : Choice
sku
exists(Item(weight * area > ($param * 453.5924)) from mm.value)
exists(Item(weight * area <= ($param * 453.5924)) from mm.value)
This did not work. This will work if I remove the formula and just do
something like exists(Item(weight > $param) from mm.value). So the
syntax is correct except for the comparison that I want to do.
Any ideas on how to do this?
Thanks.
16 years, 4 months
Authorizing the binary package URL - Drools Guvnor
by Sartaj Shaik
Hi,
I am new to drools guvnor and I have a question regarding the authorization
of binary package.
To use the rule agent, we have to call it something like..
RuleAgent agent = RuleAgent.newRuleAgent("/MyRules.properties");
RuleBase rb = agent.getRuleBase();
Following is the MyRules.properties
##
## RuleAgent configuration file example
##
newInstance=true
url=http:
//localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/XYZ/LATEST
localCacheDir=/foo/bar/cache
poll=30
name=XYZAgent
Any one who know this URL(http:
//localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/XYZ/LATEST)
can dowload my package/drl. So how can we protect it from unauthorized
access.
Thanks
Sartaj.
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
16 years, 4 months
Application based rule management
by Luiz Eduardo Guida Valmont
Hi all,
>From what I could grasp after looking at the Guvnor documentation, it
provides no API. Since it would be a (very) bad idea to re-develop such
(complex) simple feature, I'm wondering whether there is an API to manage a
set of rules, poll it for changes and update it accordingly.
I cannot use RuleAgent from drools-core since its underpinnings require that
all rules from a package be written in a single file (considering automatic
loading of all rules in a directory). I could dive into the code and adapt
the scanners to do what I want but that's not as feasible as I'd like it to
be. It's better to just use something that's been developed and tested.
Any ideas/thoughts?
Regards,
Luiz Valmont
16 years, 4 months