Drools fusion memory management
by Chris Richmond
Hello,
I wanted to ask this question in a separate email so as to keep each email
to one topic for easier thread following. Let me know if you prefer
multiple questions per email next time.
I am using Drools fusion basically with some success where I am at this
point only running some aggregates and calling some java functions when a
running average over the last 1 minute or so drops below a certain value.
The sources for those values come from objects I am injecting into memory
space, but I am not specifically calling retraction code since it is my
understanding that I can set the policy in the rule file for how long to
hold objects in memory. So for example I have this rule which simpoly
outputs to out when the average goes above 100 for the last 10 items(you can
tell I created mine based on the stock ticker). It seems to be working, but
I have some questions to ensure I understand before moving forward.
So below the "declare MyObject" with assigning it role event with a default
expiration of 2 minutes. Is my undertanding correct that fusion will
disregard thos objects that are injected without me having to take any other
action?
Also, in my "show averages" rule below, if I did ont have the "declare
MyObject" delcaration with expiration policy set, would fusion automatially
throw away MyObjects older than the last 10 based on my rule no longer
needing them? If it would, then which takes priority, the expires
declaration for MyObject or the no longer needed by my aggregate rule below.
I am assuming that the rule would keep them beyond 2 minutes it it was
necessary, but is this correct? If the rule as written would not
automatically remove objects from memory space, then is there something I
could do to tell the rule to do so when it is no longer needed by my
aggregate?
Thanks,
Chris
<imports removed>
# default dialect for the semantic code will be MVEL
dialect "mvel"
# tells the engine that a object instance will assume the
# role (semantics) of events and that the default retention
# policy will be 2 minutes
declare MyObject
@role( event )
@expires( 2m )
end
rule "show averages"
when
$n : Number( doubleValue > 100 ) from accumulate (
$stat:MyObject($bc: byteCount, srcIPAddress == "10.5.0.4") over
window:length(10) from entry-point "MyObject stream",
average( $bc )
)
then
System.err.println("average: " + $n)
end
17 years, 1 month
setFocus
by Earnest Dyke
Converting a 4.0.7 project to 5.0.1 and StatefulKnowledgeSession does not have a .setFocus method like StatefulSession has. How do I accomplish the same function in 5.0.1?
Earnie!
17 years, 1 month
Throwing runtimeException 4.0.7 not supposed
by surya_n2007
Throwing runtime exception in this example inserted person object as person
name is null. Ideally need to add error
"P01" and in second rule checks for precondition "P01" exist and skip rule.
But i am getting the below error.
Please let me know this is bug, i dont want to check again "Second Rule"
name object is not null.
I think this is happening since drools frist try to run all rules before
start execution.
please let me know whether anything wrong on my end.
Rule Engine COde :
Person person = test.new Person();
// Name name = person.new Name();
// person.setName(name);
workingMemory.insert(person);
rule "First Rule" salience 100 lock-on-active true
when
person : Person()
eval(person.name == null)
then
person.errors.add("P01");
System.out.println("Rule 1 invoked"+person.errors);
update(person);
end
rule "Second Rule" salience 99 lock-on-active true
when
person : Person()
eval(!person.errors.contains("P01"))
eval(person.name.firstName=="Bob")
then
person.name.suffix="Mr";
System.out.println("Rule 2 invoked");
end
org.drools.RuntimeDroolsException:
com.sample.Rule_Second_Rule_0Eval1Invoker@4b42aa1e :
java.lang.NullPointerException
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:82)
at
org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:148)
at
org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(SingleTupleSinkAdapter.java:29)
at
org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:157)
at
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTuple(CompositeTupleSinkAdapter.java:73)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)
at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:911)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684)
at com.sample.DroolsTest.main(DroolsTest.java:36)
Caused by: java.lang.NullPointerException
at com.sample.Rule_Second_Rule_0.eval1(Rule_Second_Rule_0.java:14)
at
com.sample.Rule_Second_Rule_0Eval1Invoker.evaluate(Rule_Second_Rule_0Eval1Invoker.java:20)
at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:77)
... 14 more
--
View this message in context: http://www.nabble.com/Throwing-runtimeException-4.0.7-not-supposed-tp2400...
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 1 month
example needed
by Parvez Shah
Is there a Pet store kind of example available which a newbie can
download and learn how actually different component in a web application
interact with drools using best practice, i have the book jboss drools
Business rule by Paul Browne, but i still feel there is a need for pet
store kind of application, can any one guide me where i can find some
appliaction using drools which i can download and understand full
capability of drools
17 years, 1 month
Timer does not return!
by Ajay.Gautam@rbs.com
I have a timer in my code that does not return. It just hangs the process (with no CPU activity).
Any idea what may be causing this?
The timer delay is 2000 ms. Based on the docs, here are code snippets:
.......
ksession = kbase.newStatefulKnowledgeSession();
new Thread(new Runnable() {
public void run() {
ksession.fireUntilHalt();
}
}).start();
........
final RFQRequest req = createRequest();
parameters.put("rfqIn", req);
ksession.setGlobal("reqTag", req.getTag());
ksession.startProcess("com.rbs.gbm.pm.RFQ-WorkFlow", parameters);
........
If I remove the fireUntilHalt thread, the timer is not triggered at all. The flow just passes through it lilke its not even there.
Any help / info / pointers will be appreciated.
Thanks
Ajay
*****Please note that my email address may have changed. For all
future correspondence, please use this address*****
********************************************************************This
message (including any attachments) is confidential and/or
privileged. It is to be used by the intended recipients only. If
you have received it by mistake please notify the sender by return
e-mail and delete this message from your system. Any unauthorized
use or dissemination of this message in whole or in part is
strictly prohibited. Please note that e-mails are inherently
insecure and susceptible to change. The Royal Bank of Scotland
Group, plc ("RBS") and its US subsidiaries, and affiliates and
subsidiary undertakings, including but not limited to, RBS plc New
York and Connecticut Branches, RBS Securities Inc., ABN AMRO Bank
N.V. New York and Chicago Branches and, ABN AMRO Incorporated,
Citizens Financial Group, Inc. and RBS Citizens, N.A., shall not be
liable for the improper or incomplete transmission of the
information contained in this communication or Attachment nor for
any delay in its receipt or damage to your system. RBS does not
guarantee that the integrity of this communication has been
maintained nor that this communication is free of viruses,
interceptions or interference. RBS and its subsidiaries and
affiliates do not guarantee the accuracy of any email or
attachment, that an email will be received or that RBS or its
affiliates and subsidiaries will respond to an email.
RBS makes no representations that any information contained in this
message (including any attachments) are appropriate for use in all
locations or that transactions, securities, products, instruments
or services discussed herein are available or appropriate for sale
or use in all jurisdictions, or by all investors or counterparties.
Those who utilize this information do so on their own initiative
and are responsible for compliance with applicable local laws or
regulations.********************************************************************
17 years, 1 month
Drools in the real world
by Ajay.Gautam@rbs.com
Are people actually using Drools Or Drools Flow in production?
The traffic on this list seems way too low to suggest any serious industry consideration.
OTOH, there are books out there for Drools. Which does suggest serious usage.
What am I missing?
Ajay Gautam
*****Please note that my email address may have changed. For all
future correspondence, please use this address*****
********************************************************************This
message (including any attachments) is confidential and/or
privileged. It is to be used by the intended recipients only. If
you have received it by mistake please notify the sender by return
e-mail and delete this message from your system. Any unauthorized
use or dissemination of this message in whole or in part is
strictly prohibited. Please note that e-mails are inherently
insecure and susceptible to change. The Royal Bank of Scotland
Group, plc ("RBS") and its US subsidiaries, and affiliates and
subsidiary undertakings, including but not limited to, RBS plc New
York and Connecticut Branches, RBS Securities Inc., ABN AMRO Bank
N.V. New York and Chicago Branches and, ABN AMRO Incorporated,
Citizens Financial Group, Inc. and RBS Citizens, N.A., shall not be
liable for the improper or incomplete transmission of the
information contained in this communication or Attachment nor for
any delay in its receipt or damage to your system. RBS does not
guarantee that the integrity of this communication has been
maintained nor that this communication is free of viruses,
interceptions or interference. RBS and its subsidiaries and
affiliates do not guarantee the accuracy of any email or
attachment, that an email will be received or that RBS or its
affiliates and subsidiaries will respond to an email.
RBS makes no representations that any information contained in this
message (including any attachments) are appropriate for use in all
locations or that transactions, securities, products, instruments
or services discussed herein are available or appropriate for sale
or use in all jurisdictions, or by all investors or counterparties.
Those who utilize this information do so on their own initiative
and are responsible for compliance with applicable local laws or
regulations.********************************************************************
17 years, 1 month
Re: [rules-users] Drools in the real world
by Michael Rhoden
We have been using Drools since version 2, and currently have well over 10,000 rules in production. It is a very solid product that can be used anywhere an Ilog etc would be considered. Drools Flow is a bit new, although I know there are several companies who have it in production. We are currently testing it internally, and it shows huge promise.
-Michael
----- Original Message -----
From: "Ajay Gautam" <Ajay.Gautam(a)rbs.com>
To: rules-users(a)lists.jboss.org
Sent: Friday, June 12, 2009 8:28:26 AM GMT -06:00 US/Canada Central
Subject: [rules-users] Drools in the real world
Are people actually using Drools Or Drools Flow in production?
The traffic on this list seems way too low to suggest any serious industry consideration.
OTOH, there are books out there for Drools. Which does suggest serious usage.
What am I missing?
Ajay Gautam
*****Please note that my email address may have changed. For all
future correspondence, please use this address*****
********************************************************************This
message (including any attachments) is confidential and/or
privileged. It is to be used by the intended recipients only. If
you have received it by mistake please notify the sender by return
e-mail and delete this message from your system. Any unauthorized
use or dissemination of this message in whole or in part is
strictly prohibited. Please note that e-mails are inherently
insecure and susceptible to change. The Royal Bank of Scotland
Group, plc ("RBS") and its US subsidiaries, and affiliates and
subsidiary undertakings, including but not limited to, RBS plc New
York and Connecticut Branches, RBS Securities Inc., ABN AMRO Bank
N.V. New York and Chicago Branches and, ABN AMRO Incorporated,
Citizens Financial Group, Inc. and RBS Citizens, N.A., shall not be
liable for the improper or incomplete transmission of the
information contained in this communication or Attachment nor for
any delay in its receipt or damage to your system. RBS does not
guarantee that the integrity of this communication has been
maintained nor that this communication is free of viruses,
interceptions or interference. RBS and its subsidiaries and
affiliates do not guarantee the accuracy of any email or
attachment, that an email will be received or that RBS or its
affiliates and subsidiaries will respond to an email.
RBS makes no representations that any information contained in this
message (including any attachments) are appropriate for use in all
locations or that transactions, securities, products, instruments
or services discussed herein are available or appropriate for sale
or use in all jurisdictions, or by all investors or counterparties.
Those who utilize this information do so on their own initiative
and are responsible for compliance with applicable local laws or
regulations.********************************************************************
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
17 years, 1 month
How to write DSL for relation between two objects
by Flavius Vespasianus
Hi,
I'd like to write in my DSL in LHS questions as
rule "Relation"
when
relation between "a" and "b" is "x"
then
do something
end
The "relation between..." can be rewritten as
relation between "{var1}" and "{var2} is "{relation}" =
$a: A(name == "{var1}")
$b: A(name == "{var2}")
eval(A.getRelation($a, $b) == "{relation}")
But the problem is that if I write
when
relation between "a" and "b" is "x"
relation between "c" and "d" is "y"
then...
the variables $a and $b collide.
It could be solved as to use $a{var1} instead of $a, but this forces the
user to use only names without spaces and special characters. And the
bigger problem is that I still cannot write
relation between "a" and "b" is "x"
or
relation between "a" and "b" is "y"
Is there any way to make the variables "local" withing some block? Or do
I need to force user to manually set names for those variables?
Thanks for any suggestions
Flavius
17 years, 1 month
RE: [rules-users] Constaint evaluation
by Greg Barton
Correct. When there are no more instantiations (a rule plus a set of objects that match the rule's conditions) on the agenda, then rule firing ceases. With version 5 of drools they added the ability to keep the session ready and available to react even when there are no instantiations on the agenda, but you must make a separate method call to do that. (StatefulSession.fireUntilHalt() instead of fireAllRules())
--- On Wed, 6/10/09, Malenfant, Andre <andre.malenfant(a)cgi.com> wrote:
> From: Malenfant, Andre <andre.malenfant(a)cgi.com>
> Subject: RE: [rules-users] Constaint evaluation
> To: "Rules Users List" <rules-users(a)lists.jboss.org>
> Date: Wednesday, June 10, 2009, 2:55 PM
> Ok, so now I understand that the
> "immutable" is really a concept but not necessarily
> "enforced". So, the rule conditions get evaluated each time
> the working memory is updated (and not globals) and rules
> for which the conditions are true at each evaluation will
> fire. The execution of the rules will end when there is no
> more rules for which the conditions are true. Am I correct?
>
> Thanks
>
> -----Original Message-----
> From: rules-users-bounces(a)lists.jboss.org
> [mailto:rules-users-bounces@lists.jboss.org]
> On Behalf Of Greg Barton
> Sent: Wednesday, June 10, 2009 3:49 PM
> To: Rules Users List
> Subject: RE: [rules-users] Constaint evaluation
>
>
> The ideas is that objects in working memory are those that
> meant to be tracked: their changes are made visible to the
> rules via the insert/update/retract methods. A global
> is not in working memory, so it's changes cannot be
> tracked. You can change the contents of a global all
> day long and the rules would never be notified.
>
> It's a similar concept to threads and
> synchronization. You can have unsynchronized access to
> member variables in a class when in a multithreaded
> environment, but the results are unpredictable.
> Likewise, you can use globals in conditions, and change the
> value of the global as you go, but the results are
> unpredictable.
>
> --- On Wed, 6/10/09, Malenfant, Andre <andre.malenfant(a)cgi.com>
> wrote:
>
> > From: Malenfant, Andre <andre.malenfant(a)cgi.com>
> > Subject: RE: [rules-users] Constaint evaluation
> > To: "Kris Verlaenen" <Kris.Verlaenen(a)cs.kuleuven.be>
> > Cc: "Rules Users List" <rules-users(a)lists.jboss.org>
> > Date: Wednesday, June 10, 2009, 2:20 PM
> > Thanks Kris,
> >
> > I will try with code constraints.
> >
> > But on the globals subject, I read in the
> documentation
> > that one should not use a global in a rule. I have
> trouble
> > understanding why. I don't think drools clones the
> global
> > object (might not be possible anyway). If my rule
> > consequences change the state of a global (this usage
> is
> > considered valid as per the documentation as well)
> then what
> > is the harm of using it in a condition? I could
> understand
> > with immutable objects like String but...
> >
> > I can change my code to insert that global in the
> working
> > memory but I would like to understand why I should do
> so...
> > And if I do and the state of that object is changed by
> a
> > consequence of my rules, I have to call update? For
> the same
> > reason? I guess I am trying to understand the
> underlying
> > mechanism.
> >
> > Thanks
> >
> >
> > -----Original Message-----
> > From: Kris Verlaenen [mailto:Kris.Verlaenen@cs.kuleuven.be]
> >
> > Sent: Wednesday, June 10, 2009 11:38 AM
> > To: Rules Users List; Malenfant, Andre
> > Cc: Rules Users List
> > Subject: Re: [rules-users] Constaint evaluation
> >
> > It depends on what type of constraint you are using.
> >
> > If you are using a rule constraint, that constraint
> will be
> > evaluated
> > just the same as normal rules. This means that the
> > constraints are
> > evaluated when data is inserted / updated /
> removed.
> > Note that, if you
> > want to make sure the engine is using up-to-date
> > information, you must
> > notify the engine (using update) when you change the
> data
> > in the working
> > memory. Also note that globals are considered
> > immutable. You should
> > never write rules that depend on the state of a global
> and
> > where the
> > global can be changed.
> >
> > If you are using code constraints, the constraint is
> > evaluated at the
> > point the code constraint is reached.
> >
> > Kris
> >
> > Quoting "Malenfant, Andre" <andre.malenfant(a)cgi.com>:
> >
> > > I have some trouble understanding how conditions
> and
> > constraints are
> > > evaluated:
> > >
> > > I have a rule flow split node with constraints on
> a
> > global object.
> > > The split node always takes the same path like if
> the
> > constraints are
> > > evaluated at the beginning of the execution of
> the
> > process and not
> > > when the process flow reaches that split node.
> What I
> > would expect is
> > > that the split node constraints takes into
> account the
> > state of the
> > > global object as modified by previous rules in
> the
> > flow.
> > >
> > > Am I right to think that rules conditions and
> split
> > nodes constraints
> > > are evaluated only when inserting/updating
> objects in
> > the working
> > > memory? The documentation is not really useful
> (unless
> > I haven't
> > > found the appropriate one).
> > >
> > > Thanks
> > >
> > > André
> > >
> > > -----Original Message-----
> > > From: rules-users-bounces(a)lists.jboss.org
> > > [mailto:rules-users-bounces@lists.jboss.org]
> > On Behalf Of Malenfant,
> > > Andre
> > > Sent: Wednesday, June 10, 2009 11:07 AM
> > > To: Kris Verlaenen
> > > Cc: Rules Users List
> > > Subject: RE: [rules-users] Globals in ruleflow
> > >
> > > Thanks for trying this for me...
> > >
> > > As it turns out, while I was creating a test
> sample
> > for you I
> > > realized
> > > that my ruleflow was not loading properly and I
> forgot
> > to check for
> > > errors on the builder. Now it works.
> > >
> > > Still, the behavior is strange. If my rule
> doesn't
> > load and even
> > > though
> > > my DRL loaded, my globals were not available.
> Since
> > the DRL declared
> > > the
> > > same globals it should not have given me that
> error.
> > >
> > > Thanks
> > >
> > > -----Original Message-----
> > > From: Kris Verlaenen [mailto:Kris.Verlaenen@cs.kuleuven.be]
> >
> > > Sent: Tuesday, June 09, 2009 5:51 PM
> > > To: Rules Users List; Malenfant, Andre
> > > Cc: Rules Users List
> > > Subject: Re: [rules-users] Globals in ruleflow
> > >
> > > Andre,
> > >
> > > There should be no problem in using the same
> global in
> > both your
> > > rules
> > > and processes.
> > >
> > > I have tried a simple example as you described
> but
> > have not been able
> > > to
> > > reproduce the problem. Could you send me a
> > self-contained example
> > > that
> > > shows the issue?
> > >
> > > Kris
> > >
> > > Quoting "Malenfant, Andre" <andre.malenfant(a)cgi.com>:
> > >
> > > > I am experimenting with rule flows and I get
> the
> > following error:
> > > >
> > > > Unexpected global [myglobal]
> > > >
> > > > When calling setGlobal on the session.
> > > >
> > > > This code works without the workflow
> (globals
> > declared in the drl)
> > > > but
> > > > fails when I include the rule flow. I
> declared
> > the same globals in
> > > > the
> > > > rule flow in the header section.
> > > >
> > > >
> _______________________________________________
> > > > rules-users mailing list
> > > > rules-users(a)lists.jboss.org
> > > > https://lists.jboss.org/mailman/listinfo/rules-users
> > > >
> > >
> > >
> > >
> > >
> > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
> > >
> > > _______________________________________________
> > > rules-users mailing list
> > > rules-users(a)lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/rules-users
> > >
> > > _______________________________________________
> > > rules-users mailing list
> > > rules-users(a)lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/rules-users
> > >
> >
> >
> >
> >
> > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
17 years, 1 month