Newbie: Drools and this multi-user/domain scenenario realization
by Peter Schmidt
Hello all:
Being new to Drools, I'm currently uncertain if it's "a good idea" to use
Drools for the following "multi-domain" scenario.
-- I guess Drools is appropriate, but I currently can't imagine (a) which
Drools parts to configure after which strategies (static/cachable vs.
dynamic), and thus also (b) how to organize the rule structures and their
goals (what input/output, what is cachable).
The scenario is as follows:
A /Businesses Service/ *Java Web App* shall manage /N/ distinct shops for
/N/ distinct shop owners, thus having /N/ "domains" with their own fact
model (extended from basic model that is the same for all shops), their own
rules, etc.
The shared but extensible 'Product' model is for rather *static* product and
product set definitions, and it basically consists of:
(a) some basic attributes (product name, description, etc.) AND
(b) several custom (=dynamic) attributes, independly definable by each
shop owner (attrib name, type, value(s)).
Non-technical shop owners define their products, "product sets", customer
types, and last but not
least use the "price model" to assign prices to products and product sets,
depending on some fixed
(e.g. customer_type ::= {NEW_CUSTOMER, REGULAR_CUSTOMER, VIP,...}, taxes,
etc.) and probably some custom price aspects like:
- quantity ranges,
- charges for a specific dyn. product attribute (e.g. t-shirts of
'size==XXL' => +10% of basic price),
- additional promotional price discounts (or charges) for specific
products or sets.
Product defs and taxes are rather /static/ once created, whereas prices and
discounts are /highly dynamic/, i.e. should be externally changeable at need
by the non-technical shop owners (IMHO /decision tables/ are the most
appropriate way here).
Customers are presented a shop's Online Catalog (or Ordering Form) showing
the prices intended for them, of course, but probably also the other
customer-type specific prices -- for them to see their current savings or
the possible savings after a customer-type "upgrade".
Finally, customers place orders via the web interface and the system
processes these orders (via further rules). ...
My unclarities are:
For the rather static "product (set) definitions" (both type def & instance
data),
Should I better use a traditional way via *configuration files* OR
could I use Drools with
some kind of "product definition rules" (generated from /decision
tables/)???
What is a good strategy for realizing the "product def rules" in
Drools? I.e.,
What is static and what dynamic? What is generated once vs. in
real-time, and what is cached vs. physically stored in the database?
For the highly dynamic "price assignments" (after some pre-defined as well
as custom pricing aspects):
How could a pricing table with custom pricing parameters look like? OR
equivalently:
How to define a pricing rule that dependens on a custom product
attribute?
The intention is similar to:
WHEN ( aProduct.extendedAttributes.size == 'XXL' )
THEN ( aProduct.price = aProduct.standardPrice * 1.10 ) //+10% of std.
price
When would the defined pricing rules run and what would they generate?
-- I.e., will all rules re-run each time a rule file changes with the
goal of generating cacheable "price lists", or will they even run on any
catalog request (thus generating the price lists on-the-fly)???
In such a not so uncommon JavaEE Web App shopping scenario:
Generally, which kind of rules are feasible besides the "product (set)
definition" and "price controling" rules?
I guess rules such as the following could be practicable:
fact model type definition rules (that construct and load new model types).
GUI generation rules for Swing/SWT and Web GUIs (after some
type-to-component mappings configured via rules or decision tables).
authentication & authorization rules.
Knowing the required artefacts and their generation strategies (cached vs.
life) from the answers of the above questions:
How do I have to configure Drools (& Guvnor) for *N parallel running* online
shops? I.e.,
Do I instantiate 1 rule engine per shop, or do I share 1 for all shops?
Do I load the generic fact model (that supports custom enhancements) once
per shop, or share it among them?
Which parts can be cached in "Application Scope"? (supposable N
KnowledgeBases with pre-generated stuff, 1 for each shop)
In which kind of JEE Session Beans do I have to integrate which kind of
Drools Knowlege Session beans?
The clarification of these issues would currently help me a lot.
Thank you very much for any help and development hints in advance.
Best regards
Peter
--
View this message in context: http://drools.46999.n3.nabble.com/Newbie-Drools-and-this-multi-user-domai...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 2 months
Bulk modification
by Rodrigo Goncalves
Hi,
How can I modify all objects resulted from a collect operation?
I would like to do something like this: (The following does not work)
rule "test"
when
exists (MyClass());
$l : ArrayList() from collect (MyClass (attribute == false));
$r : AnotherClass();
then
$r.doSomething($l);
for(Object o : $l) {
MyClass o2 = (MyClass) o;
modify(o2) { setAttribute(true); } ;
}
end
I do not want to do:
rule "test"
when
$o : MyClass(attribute == false)
$r : AnotherClass()
then
$r.doSomething($o);
modify(o) {setAttribute(true);};
end
because I need to do a bulk operation… Doing it one by one is extremely inefficient in my case.
Thanks!
Rodrigo.
13 years, 3 months
Trapping runaway rules
by Dean Whisnant
My project involves rule creation by customers, business analysts, and developers. We have a base set of rules that fire for every transaction and then we fire custom rules within a stateful session. An issue I've started to run into is rules being created that fire endlessly. I initialize the session with an event listener that we use to extract all rules fired for each line item of a transaction. Once the session is initialized and all rules from various agenda groups loaded we do a fireall rules.
My questions are:
1) how can I detect I have a runaway rule/rules.
Is there a method or listener that could detect this for me? Does anyone have a formula they use to do so? I had thought that I could use my event listener that I track the rules with to grab the last X number of rules fires and see if rule y gets fired more that z times. But is there a simpler method?
2) once I've detected a runaway rule, how can I gracefully stop drools rule execution? I read of the command drools.halt in different posts, but not sure if this would be what I'm looking at doing.
Any thoughts are appreciated.
Thank you!
Dean
StatefulKnowledgeSession ksession = buildOutgoingStatefulKnowledgeSession(supportingUDTList);
// AgendaEventListener agendaListener = new HipaaAgendaListener();
ksession.addEventListener(_ruleLog);
for (int i = 0; i < _agendaGroups.size(); i++)
{
if (_log.isDebugEnabled()) _log.debug("Focus on Agenda Group " + _agendaGroups.get(i));
ksession.getAgenda().getAgendaGroup(_agendaGroups.get(i)).setFocus();
// Fire them all
try
{
ksession.fireAllRules();
}
catch (Exception e)
{
_log.error("FireAllRules exception. Error=" + e.getMessage()); // error
}
}
13 years, 3 months
accessing items from the StatelessKnowledgeSession
by Warner Onstine
I have passed in some lists into the
StatelessKnowledgeSession.execute() method and would like to figure
out how to get access.
I have the following items passed in:
- Player
- EarnedBadges (list)
- Badges (list)
and am trying to do something like this:
not (EarnedBadge(playerId == $player.id, badge == $badge) from $earnedBadges)
but it doesn't know how to evaluate earnedBadges (the name of the
variable I passed in):
[Unable to Analyse Expression $earnedBadges:
[Error: unable to resolve method using strict-mode:
java.lang.Object.$earnedBadges()]
[Near : {... $earnedBadges ....}]
Been searching through the docs on how to do this but I haven't found
anything yet.
Any help is greatly appreciated, thank you! :-).
-warner
13 years, 3 months
Getting one type from a collection of multiple types
by lhorton
The following code works, but I think it's ugly.
the classes are:
DescribedAddress is a base class for addresses
VendorAddress extends DescribedAddress and implements method abcScore()
Step getLocations() is defined as a list of DescribedAddress objects but it
can also contain VendorAddress objects since they are a kind of
DescribedAddress
the LHS of the rule below extracts the VendorAddress with the highest
abcScore from step.locations
if I omit the eval(), i get ClassCastException on any DescribedAddress in
locations, since DescribedAddress cannot be cast to VendorAddress.
is there a more elegant / clean / efficient way to get only the
VendorAddress objects from locations?
rule "Find highest scored address"
dialect "mvel"
when
$step : Step()
$location : VendorAddress (eval($location instanceof VendorAddress ),
abcScore>9) from $step.getLocations()
not $addr : VendorAddress (eval($addr instanceof VendorAddress
),abcScore > $location.abcScore) from $step.getLocations()
then
System.out.println("high score is: " + $location.getAbcScore());
end
--
View this message in context: http://drools.46999.n3.nabble.com/Getting-one-type-from-a-collection-of-m...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
reloadKnowledgeBase java.lang.NullPointerException
by ayonchak
Hi All,
I am getting Nullpointer exception the application is trying to
reloadKnwledgeBase. I have the following code in application.
public void init() {
logger.info("Group Rule Engine Initiated..!!");
/**
* Polling interval needs to be externalized
*/
knowledgeAgent = KnowledgeAgentFactory.newKnowledgeAgent("FiveSeries");
knowledgeAgent.applyChangeSet(ResourceFactory
.newFileResource(propertyReader
.getProperty("DROOLS_GUVNOR_CHAGNE_SET_XML_PATH")));
ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();
if (knowledgeAgent != null && knowledgeAgent.getKnowledgeBase()!=null &&
!knowledgeAgent.getKnowledgeBase().getKnowledgePackages().isEmpty()) {
knowledgeBase = knowledgeAgent.getKnowledgeBase();
}
logger.info("Group Rule Engine is ready to use..!!");
}
public void reloadKnowledgeBase() {
if (knowledgeAgent != null && knowledgeAgent.getKnowledgeBase()!=null &&
!knowledgeAgent.getKnowledgeBase().getKnowledgePackages().isEmpty()) {
knowledgeBase = knowledgeAgent.getKnowledgeBase();
logger.debug("KnowledgeBase reloaded..!!");
} else {
logger.info("KnowledgeBase not reloaded..!!");
ResourceFactory.getResourceChangeScannerService().stop();
ResourceFactory.getResourceChangeNotifierService().stop();
init();
}
}
reloadKnowledgeBase() is called once in application during Login. The
problem is occurring in Development application. When I am using that
Change-Set.xml in my local application, it is working perfectly fine. I m
not getting the problem. I bounced both Jboss and application servers but
still no luck!
--
View this message in context: http://drools.46999.n3.nabble.com/reloadKnowledgeBase-java-lang-NullPoint...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
resource Allocation in Drools planner
by tzimis
Hi I’m newbie so be generous. I’m dealing with a project for a cloud system
and I have a cp problem so any advice how to deal with it will be helpful.
Suppose that we have 5 machines each machine has the properties below:
• Sec_level: level of security that offers.
• Max_CPU: Max cpu resources that offers
• Max_Ram: Max ram resources that offers
• Max_HD: Max Storage resources that offers •
Max_Net: Max Bandwidth resources that offers
Then suppose that we have 20 VMs that must allocated to these machines Every
VM has these demands:
• Priority: The priority that this machine has.
• Min_sec_level: The minimum sec level of the machine that can service this
vm
• CPU: the cpu resources that demands
• Ram: ram resources that demands
• HD: storage resources that demands
• Net: resources that demands. We can have a solution where few Vms aren’t
allocated but the allocated Vms must have bigger priority than the
unallocated. Can anybody help me by giving me few advices hot to cope with
this problem???
--
View this message in context: http://drools.46999.n3.nabble.com/resource-Allocation-in-Drools-planner-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Rules stop firing when white-space is changed
by dcrissman
I have an issue where I am changing white-space in a drl file and suddenly
some rules stop firing, but others do not. Has anyone seen behavior like
this?
I have the resource-change-scanner configured to watch the drl file for
changes, and then the following output is displayed:
KnowledgeAgent applying ChangeSet
KnowledgeAgent new KnowledgeBase now built and in use
So the changes to the resource file are being detected and re-loaded.
--
View this message in context: http://drools.46999.n3.nabble.com/Rules-stop-firing-when-white-space-is-c...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months