Why Using "from" Always Return A New Fact?
by hyjshanghai
I am trying to understand why care should be taken to use "from" and
"lock-on-active" together, as is described in "Section 4.8.3.8. Conditional
Element from" of
http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/ht...
the Drools Reference Document .
It says "the use of from returns a new fact for all intents and purposes
each time it is evaluated." Why is it true?
Below is the full related-text copied from the Drools Reference Document for
your reference:
=== BEGIN ===
You must take caution, however, when using from, especially in conjunction
with the lock-on-active rule attribute as it may produce unexpected results.
Consider the example provided earlier, but now slightly modified as follows:
rule "Assign people in North Carolina (NC) to sales region 1"
ruleflow-group "test"
lock-on-active true
when
$p : Person( )
$a : Address( state == "NC") from $p.address
then
modify ($p) {} #Assign person to sales region 1 in a modify block
end
rule "Apply a discount to people in the city of Raleigh"
ruleflow-group "test"
lock-on-active true
when
$p : Person( )
$a : Address( city == "Raleigh") from $p.address
then
modify ($p) {} #Apply discount to person in a modify block
end
In the above example, persons in Raleigh, NC should be assigned to sales
region 1 and receive a discount; i.e., you would expect both rules to
activate and fire. Instead you will find that only the second rule fires.
If you were to turn on the audit log, you would also see that when the
second rule fires, it deactivates the first rule. Since the rule attribute
lock-on-active prevents a rule from creating new activations when a set of
facts change, the first rule fails to reactivate. Though the set of facts
have not changed, the use of from returns a new fact for all intents and
purposes each time it is evaluated.
=== END ===
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Why-Using-from-Always...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 10 months
Re: [rules-users] Drools Release 5.2
by Rob Fisher
Mark
Any chance you have an ETA for 5.2?
Thanks
Rob
Date: Thu, 20 Jan 2011 06:18:24 -0800 (PST)
From: alim <audrey.lim(a)it-vision.com>
Subject: [rules-users] Drools Release 5.2
To: rules-users(a)lists.jboss.org
Message-ID: <1295533104306-2294771.post(a)n3.nabble.com>
Content-Type: text/plain; charset=us-ascii
Hi,
I was wondering if there's already a planned release date for Drools
Version
5.2?
Kindest regards,
Audrey
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Release-5-2-t
p2294771p2294771.html
Sent from the Drools - User mailing list archive at Nabble.com.
------------------------------
Message: 4
Date: Thu, 20 Jan 2011 14:39:38 +0000
From: Mark Proctor <mproctor(a)codehaus.org>
Subject: Re: [rules-users] Drools Release 5.2
To: rules-users(a)lists.jboss.org
Message-ID: <4D38492A.2020206(a)codehaus.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 20/01/2011 14:18, alim wrote:
> Hi,
>
> I was wondering if there's already a planned release date for Drools
Version
> 5.2?
no planned date yet.
We are currently moving Guvnor of extjs, which is about 80% done. When
that is done we'll look at pushing out a release.
Mark
> Kindest regards,
> Audrey
13 years, 10 months
Drools with Hibernate, with dynamic types
by Gabor Szokoli
Hi,
I'm gathering the requirements for an odd system project, and I have a
design idea that is centered around Drools. I'd like to hear everyones
opinion.
The project is in a really early stage of conceptual analysis, and I'm
also near the start on the winding road exploring Drools.
The requirements call for a generic service application that performs
database operations in response to service requests.
Service logic should be editable by domain experts, not programmers.
(Enter Drools Flow due to the procedural nature of the domain logic.)
Trouble is, the exact database schema, thus the entity types are not
known at compile time, only at the time of deployment. (In fact may
differ across deployments.)
So here's the idea:
At deployment time I can convert the local database schema and domain
logic description into both Drools rules/processes with type
definitions, and matching hibernate/ibatis/JPA mappings for the java
types defined via Drools.
Drools would do the runtime bytecode generation for the entities and
request objects its rules/process steps will operate on at deployment
time.
Then the ORM can instantiate the object network of entities from the
database. (a few thousand entities, not a real big database.)
All entities are inserted as facts in a forever-running session.*
At each service request, the service connector would use reflection to
create and populate a request object, and trigger a short-lived Drools
Process.
The user defined logic is executed, and if all went well, entity state
is persisted back into the database for Durability.
Servicing the requests sequentially is acceptable, so I'm not thinking
about concurrency and Isolation yet.
(I can always throw more worker threads at the problem with separate
Working Memories, coupled by the L2 cache of the ORM I guess.)
*: It's of course not critical for the KnowledgeSession to live
forever: The working memory can be re-created from the database at any
time.
Does this sound doable? Is there any obvious flaw you guys can spot
right away maybe?
The alternative would be reading the database contents into Maps
instead of typed entities with dynamically generated types, but that
would drain all the elegance out of the Drools rules:
when
$p = PalpusztaiCheese(smell>11)
then
modify($p) { setQA("pass"); }
end
becomes
when
$m = Map()
eval( "PalpusztaiChese".equals($m.get("type")) )
eval((Integer)$m.get("smell") > 11 )
then
modify($m) { set("QA","pass"); }
end
(A DSL could completely hide this difference though, couldn't it?)
Thanks for any ideas!
Gabor Szokoli
13 years, 10 months
Drools repository and accessing the rules engine from vb.net
by Gorantla, Bhaskar (GE Capital)
I would appreciate if you could please answer the following questions.
1. Can you share some information on the out of the box repository? Is
it a relational database or is it an embedded database such as Berkley DB?
2. Can we make Guvnor to store the rules in an Oracle database?
3. Ways in .net application can access the rules engine to execute the
rules
Thanks
Bhaskar
13 years, 10 months
Salience
by huionn
If I have a rule like below:
rule "#1"
when
$i : Item(type == 1)
then
retract ($i)
// do something...
end
rule "#2"
when
$i : Item(type == 2)
then
retract ($i)
// do something...
end
// to handle other type of Item
rule "#catch-all"
salience -10
when
$i : Item()
then
retract ($i)
// do something...
end
As it is known, reliance on salience is bad practice and its order is not
guaranteed (as shown in Sudoku example).
My question is: what is the simple and good practice to emulate "else" (rule
"#catch-all") without reliance on salience? It seems ruleflow is not
applicable here as well.
Thanks and best regards.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Salience-tp2289179p22...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 10 months
Need clarification in dslr conversion
by Bala
Hi,
Please find the below sample dsl and dslr, in which only the keyword part is
alone getting converted in dslr. condition scope is not getting converted
when i look at the generated drl file. But when i change the scope from
condition to keyword, its getting converted.. am i missing something...
eg: [condition][]Get a Customer=$Customer : CustomerInfoType() is not
getting converted..
sample DSL
**********
[keyword][][Ii][fF]=when
[keyword][]Start Rule {ruleName}=rule {ruleName}
[keyword][]Template Header=template header
[keyword][]Start Template : "{tamplateName}"=template "{tamplateName}"
[keyword][]Finish Template=end template
[keyword][]FieldName {field}={field}
[keyword][]Start template Rule"{ruleName}"=rule
"{ruleName}__(a){row.rowNumber}"
[keyword][]Finish Rule=end
[keyword][][Aa]dd [Rr]ule [Ii]nfo :
{attribute}("{value}")=@{attribute}("{value}")
[condition][]1st=1
[condition][]2nd=2
[condition][]3rd=3
[condition][]Get a Customer=$Customer : CustomerInfoType()
[condition][]-with {fieldName} as {value}=${fieldName} : {fieldName},
{fieldName}=={value}
sample dslr
**********
expander pricingRules.dsl
Start Rule "AutoRatingDemo"
Add Rule Info : subRuleName("test")
Add Rule Info : author("Vishal Kaushik")
Add Rule Info : DateOfCreation("19-Jan-2011")
when
Get a Customer
-with customerCode as "23470942810"
then
end
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Need-clarification-in...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 10 months
Doubts in Using RulesBase object
by Nikhil S. Kulkarni
Hi All,
I am using JBOSS Rules 5.0.0, in which I am creating multiple RuleBase object based on package passed to it.
e.g.
public RuleBase (Package pkg)
{
RuleBase rb = RuleBaseFactory.newRuleBase();
rb.addPackage(pkg);
return rb;
}
Though I know that creating RuleBase object every time will have huge performance impact but it is required because when Multiple requests will
Come on the application server based on functionality that need to be triggered based on click of different buttons which internally call Rules.
So I am trying another option by declaring RuleBase as Static Object so that it will be shared across application, but I am facing two issues in that
Suppose I am using single RuleBase object then all the packages will be there that will be added using the above method on click of buttons which internally
Call rules by multiple users.
1) Now my problem is I cannot remove package after finish of my task as user because if Suppose two users A and B are performing the same task using different
Login. Now as User A, if he removes the package after its processing of rules completed then User B will not find that package for doing its task because if they both pass the above method at same time then both fill find package present in RuleBase.
2) If I keep all the packages as it is in RuleBase then Rules Engine will be triggered for all Rules present in all packages satisfying when condition.
So I am not able to understand what I exactly should do because currently I am facing performance issues in application and I think the Reason
is multiple RuleBase objects.
I have to change this So can anyone suggest me what I should do ??
Waiting for Reply.
Thanks & Regards,
Nikhil S. Kulkarni
MASTEK LTD.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 years, 10 months
Greater than or less than in eval
by Mohod, Akash
Hi,
I am trying to write the following rule using Drools 5.1 but having issues.
when
Employee ($name : name, $ age : age)
Event ($eventName : eventName , $ageLimit : ageLimit)
eval($age < $ ageLimit)
then
System.out.println (" Can participate in the event ");
end
The rule fails to compile.
Regards,
Akash
--------------------------------------------------------------------------
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers. If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.
13 years, 10 months