Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
take a simple scenario: when condition1 condition2 then ... Does the condition2 gets executed even if the condition1 is false, normally it should not because the conditions in the when are actually combined with an AND. Has anywhen tried this?? -- View this message in context: http://drools.46999.n3.nabble.com/Drools-all-lhs-execute-before-all-the-rhs-i-want-to-run-sequentially-tp3368215p3368464.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
This isn't an if statement evaluated left to right with an && between each part. Drools uses the rete algorithm to make execution more efficient. Put very simply (and probably inaccurately) Rete creates an evaluation tree where inputs are put in the top and activations come out the end. In this case the tree would have: One node that evaluated condition1, this node outputs a list of all the facts that matches it. A node for condition 2 which outputs a list all the facts that match that condition. A node for the rule, this takes the outputs of the other two nodes and produces an activation for each pair of items (assuming condition 1 and 2 aren't related). If you had another rule with condition1 and condition3 then they would both share the first node greatly improving efficiency and re-evaluation time. Thomas > -Original Message- > From: rules-users-boun...@lists.jboss.org [mailto:rules-users- > boun...@lists.jboss.org] On Behalf Of Saurabh Pandey > Sent: 26 September 2011 08:15 > To: rules-users@lists.jboss.org > Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want > to > run sequentially > > take a simple scenario: > when > condition1 > condition2 > then > ... > > Does the condition2 gets executed even if the condition1 is false, normally it > should not because the conditions in the when are actually combined with an > AND. Has anywhen tried this?? > > -- > View this message in context: http://drools.46999.n3.nabble.com/Drools-all- > lhs-execute-before-all-the-rhs-i-want-to-run-sequentially- > tp3368215p3368464.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
You missed the second part of the instructions - once a rule has matched you need to make sure the other rules don't match. This can be achieved in multiple ways: Call the engines halt method - just stop evaluation. Retract the facts - then nothing else can match it. Update the facts to stop the condition from being matched - eg add a "processed" field and make the rules match only if processed is false. Insert a new fact and modify your rules to only run if that fact doesn't exist - eg add "not YourResultObject()" to the when's and "insert(new YourResultObject());" to the thens. Thomas > -Original Message- > From: rules-users-boun...@lists.jboss.org [mailto:rules-users- > boun...@lists.jboss.org] On Behalf Of Saurabh Pandey > Sent: 26 September 2011 07:49 > To: rules-users@lists.jboss.org > Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want > to > run sequentially > > @Nguy I tried salience but it just orders the execution of "when" part, but > still all when execute before the "then" parts > > -- > View this message in context: http://drools.46999.n3.nabble.com/Drools-all- > lhs-execute-before-all-the-rhs-i-want-to-run-sequentially- > tp3368215p3368415.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Weird human task behaviour
I have this strange problem, when I call int taskId = 105; // dummy taskId, the real one is obtained through TaskSummary BlockingTaskOperationResponseHandler b = new BlockingTaskOperationResponseHandler(); client.complete(taskId, "myusername", null, b); while (!b.isDone()){ b.waitTillDone(100); } System.out.println("Completed task "+taskId+" owned by user myusername."); I get this in the log: INFO [STDOUT] Completed task 105 owned by user myusername. INFO [STDOUT] Notification of completed task 104 ...and about 50 milliseconds later... INFO [STDOUT] Notification of aborted task 104 No error messages between these two notifications. I understand that these ID's are not the same because 104 is actually workItemId that holds taskId 105. The status of task 105 in the database table "task" is "Completed", but the workflow stops after it and I can't do anything about it. Is there any known issues with task persistence in JBoss 5.1 or something? -- View this message in context: http://drools.46999.n3.nabble.com/Weird-human-task-behaviour-tp3368608p3368608.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Weird human task behaviour
Ah, I forgot to mention that I'm using Drools 5.2.0 Final and jbpm 5.1.0 Final. -- View this message in context: http://drools.46999.n3.nabble.com/Weird-human-task-behaviour-tp3368608p3368638.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
these are my rules: rule "Rule 03" salience 10 when $info : RuleRunner() eval(RuleRunner.check()) eval(RuleRunner.setIt()) then System.out.println("3**"); $info.printResult(1); end rule "Rule 04" salience 8 when $info : RuleRunner() eval(RuleRunner.check()) then System.out.println("4**"); $info.printResult(2); end these are my java methods: static boolean cvar = true; public void printResult(int i){ System.out.println(i); } public static boolean check(){ System.out.println("check**"); return cvar; } public static boolean setIt(){ cvar = false; return true; } this is how i am invoking the rules: KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newFileResource("rule03.drl"), ResourceType.DRL ); if ( kbuilder.hasErrors() ) { System.err.println( kbuilder.getErrors().toString() ); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() ); StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(); ksession.execute(new RuleRunner()); This is the output: check** 3** 1 4** 2 Why is check printing only once though its called 2 times in 2 rules, and when cvar is false then also 2nd rule's then part is executing? Is it that static methods of same name are called once and there result is stored and used in all rules?? -- View this message in context: http://drools.46999.n3.nabble.com/Drools-all-lhs-execute-before-all-the-rhs-i-want-to-run-sequentially-tp3368215p3368864.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
Have you read the expert guide? http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html_single/index.html - At least up to the end of chapter 4. Why are you using static fields and methods? You are changing the value of objects in the when condition which is really really really bad and it's no wonder nothing is working like you are expecting. The fact that you are using eval's is a good indication that your code is written wrong, for simple rules you never need to use it. Thomas > -Original Message- > From: rules-users-boun...@lists.jboss.org [mailto:rules-users- > boun...@lists.jboss.org] On Behalf Of Saurabh Pandey > Sent: 26 September 2011 11:22 > To: rules-users@lists.jboss.org > Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want > to > run sequentially > > these are my rules: > rule "Rule 03" > salience 10 > when > $info : RuleRunner() > eval(RuleRunner.check()) > eval(RuleRunner.setIt()) > then > System.out.println("3**"); > $info.printResult(1); > end > > rule "Rule 04" > salience 8 > when > $info : RuleRunner() > eval(RuleRunner.check()) > then > System.out.println("4**"); > $info.printResult(2); > end > > these are my java methods: > static boolean cvar = true; > public void printResult(int i){ > System.out.println(i); > } > public static boolean check(){ > System.out.println("check**"); > return cvar; > } > public static boolean setIt(){ > cvar = false; > return true; > } > > this is how i am invoking the rules: > KnowledgeBuilder kbuilder = > KnowledgeBuilderFactory.newKnowledgeBuilder(); > kbuilder.add(ResourceFactory.newFileResource("rule03.drl"), >ResourceType.DRL ); > > if ( kbuilder.hasErrors() ) { > System.err.println( kbuilder.getErrors().toString() ); > } > KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); > kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() ); > StatelessKnowledgeSession ksession = > kbase.newStatelessKnowledgeSession(); > ksession.execute(new RuleRunner()); > > > This is the output: > check** > 3** > 1 > 4** > 2 > > Why is check printing only once though its called 2 times in 2 rules, and when > cvar is false then also 2nd rule's then part is executing? > Is it that static methods of same name are called once and there result is > stored and used in all rules?? > > > -- > View this message in context: http://drools.46999.n3.nabble.com/Drools-all- > lhs-execute-before-all-the-rhs-i-want-to-run-sequentially- > tp3368215p3368864.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
@thomas thanks for your comments I am new to drools, can u plz give me an alternative to the above code. -- View this message in context: http://drools.46999.n3.nabble.com/Drools-all-lhs-execute-before-all-the-rhs-i-want-to-run-sequentially-tp3368215p3368917.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
Saurabh Pandey wrote: > @Nguy I tried salience but it just orders the execution of "when" part, > but > still all when execute before the "then" parts Hi, it seems to me that you are using the wrong tool to solve your problem. Drools is a rule-based execution engine (among other things) not a glorified if-then-else-if executor. I'd suggest you consult the Drools manual (site is off at the moment). At the beggining there is a nice section about when you could benefit from a Drools-like approach or not. If you still think that Drools is best suited for your needs, you need to rethink your approach. I would not suggest using salience as this could be mistaked as a way to force procedural logic on a system(Drools) that is inherently not so. -Stathis > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Drools-all-lhs-execute-before-all-the-rhs-i-want-to-run-sequentially-tp3368215p3368415.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
As I said, try reading the expert doc, there's some examples in there which you can base your code on. Once you've done that or if you have any questions about the samples/what the documentation means then post them and we'd be pleased to help, but the first step is to structure your code correctly using objects that follow the bean conventions and rules structured correctly with conditions against objects and appropriate modify statements. Thomas > -Original Message- > From: rules-users-boun...@lists.jboss.org [mailto:rules-users- > boun...@lists.jboss.org] On Behalf Of Saurabh Pandey > Sent: 26 September 2011 11:51 > To: rules-users@lists.jboss.org > Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want > to > run sequentially > > @thomas thanks for your comments I am new to drools, can u plz give me an > alternative to the above code. > > -- > View this message in context: http://drools.46999.n3.nabble.com/Drools-all- > lhs-execute-before-all-the-rhs-i-want-to-run-sequentially- > tp3368215p3368917.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
Hi, If you have a lot of rules like it you might be able to use the jBPM (what what the Drools Flow) to help with this. Otherwise plan old java might be easier... Wendy From: "Swindells, Thomas" To: Rules Users List Sent: Monday, September 26, 2011 6:53 AM Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially As I said, try reading the expert doc, there's some examples in there which you can base your code on. Once you've done that or if you have any questions about the samples/what the documentation means then post them and we'd be pleased to help, but the first step is to structure your code correctly using objects that follow the bean conventions and rules structured correctly with conditions against objects and appropriate modify statements. Thomas > -Original Message- > From: rules-users-boun...@lists.jboss.org [mailto:rules-users- > boun...@lists.jboss.org] On Behalf Of Saurabh Pandey > Sent: 26 September 2011 11:51 > To: rules-users@lists.jboss.org > Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want > to > run sequentially > > @thomas thanks for your comments I am new to drools, can u plz give me an > alternative to the above code. > > -- > View this message in context: http://drools.46999.n3.nabble.com/Drools-all- > lhs-execute-before-all-the-rhs-i-want-to-run-sequentially- > tp3368215p3368917.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Regression with Drools 5.3.0-CR1
I've just tried upgrading from Drools 5.3.0-CR1 from the beta and I've hit a regression. JBoss seems to have been down for most of today so I haven't been able to raise a Jira for it. In our model we have Facts which contain fields of java.lang.class, we then have a rule which checks that they aren't null. Eg Fact { Class classField} Rule "xyz" When Fact(classField != null) Then ... End This is giving the following exception Caused by: java.lang.ClassCastException: org.drools.base.field.ObjectFieldImpl cannot be cast to org.drools.base.field.ClassFieldImpl at org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772) at org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87) at org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109) at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130) at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369) at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134) at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379) at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204) at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244) at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330) at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882) at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180) ... 149 more Wrapping the classField != null within an eval appears to be a work around. This is in the suspect method: public boolean evaluate(InternalWorkingMemory workingMemory, final InternalReadAccessor extractor, final Object object1, final FieldValue object2) { Object value1 = extractor.getValue( workingMemory, object1 ); Object value2 = object2.getValue(); if ( value2 == null ) { ClassFieldImpl classField = (ClassFieldImpl) object2; value2 = classField.resolve( workingMemory ); } return comparator.equals( value1, value2 ); } I think the if statement just needs an instanceof check as well or some other way to track the fact that null may be a valid value to be comparing with! Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Regression with Drools 5.3.0-CR1
That's a nice one.. We will definitely create a test for that.. if it's not there.. 2011/9/26 Swindells, Thomas > I’ve just tried upgrading from Drools 5.3.0-CR1 from the beta and I’ve > hit a regression. > > ** ** > > JBoss seems to have been down for most of today so I haven’t been able to > raise a Jira for it. > > ** ** > > In our model we have Facts which contain fields of java.lang.class, we then > have a rule which checks that they aren’t null. > > Eg > > Fact { Class classField} > > ** ** > > Rule “xyz” > > When > > Fact(classField != null) > > Then > > … > > End > > ** ** > > This is giving the following exception > > ** ** > > Caused by: java.lang.ClassCastException: > org.drools.base.field.ObjectFieldImpl cannot be cast to > org.drools.base.field.ClassFieldImpl > > at > org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772) > > > at > org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87)** > ** > > at > org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109)*** > * > > at > org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130) > > at > org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) > > > at > org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369) > > > at > org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134) > > at > org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) > > > at > org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379) > > > at > org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204) > > at > org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244) > > at > org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330) > > at > org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291) > > at > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882) > > > at > org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180) > > > ... 149 more > > ** ** > > Wrapping the classField != null within an eval appears to be a work around. > > > ** ** > > This is in the suspect method: > > *public* *boolean* evaluate(InternalWorkingMemory workingMemory,** > ** > > *final* InternalReadAccessor extractor,*** > * > > *final* Object object1, *final* FieldValue > object2) { > > Object value1 = extractor.getValue( workingMemory, object1 );* > *** > > Object value2 = object2.getValue(); > > *if* ( value2 == *null* ) { > > ClassFieldImpl classField = (ClassFieldImpl) object2; > > value2 = classField.resolve( workingMemory ); > > } > > *return* *comparator*.equals( value1, value2 ); > > } > > ** ** > > I think the if statement just needs an instanceof check as well or some > other way to track the fact that null may be a valid value to be comparing > with! > > ** ** > > ** ** > > Thomas > > -- > > > ** > This message is confidential and intended only for the addressee. If you > have received this message in error, please immediately notify the > postmas...@nds.com and delete it from your system as well as any copies. > The content of e-mails as well as traffic data may be monitored by NDS for > employment and security purposes. To protect the environment please do not > print this e-mail unless necessary. > > NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 > 4EX, United Kingdom. A company registered in England and Wales. Registered > no. 3080780. VAT no. GB 603 8808 40-00 > > ** > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > -- - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jugargentina.org - Co-Founder @ http://www.jbug.com.ar - Salatino "Salaboy" Mauricio - ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/
Re: [rules-users] How to terminate a StatefulKnowledgeSession
Thanks for your suggestion about activating the console logger. That helped me find out what's going on. After I fixed a stupid logic error on my part, I found out that my basic solution will work. When the user decides to cancel the session, I need to make sure that the current rule's RHS processing completes. Then, my stop rule will fire and clear the agenda, and fireAllRules() will finish normally. -- View this message in context: http://drools.46999.n3.nabble.com/How-to-terminate-a-StatefulKnowledgeSession-tp3355958p3370067.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Regression with Drools 5.3.0-CR1
Thomas, Thanks for reporting. I will look into it. Did you open a JIRA yet? Let me know or I will do it otherwise. Edson 2011/9/26 Swindells, Thomas > I’ve just tried upgrading from Drools 5.3.0-CR1 from the beta and I’ve > hit a regression. > > ** ** > > JBoss seems to have been down for most of today so I haven’t been able to > raise a Jira for it. > > ** ** > > In our model we have Facts which contain fields of java.lang.class, we then > have a rule which checks that they aren’t null. > > Eg > > Fact { Class classField} > > ** ** > > Rule “xyz” > > When > > Fact(classField != null) > > Then > > … > > End > > ** ** > > This is giving the following exception > > ** ** > > Caused by: java.lang.ClassCastException: > org.drools.base.field.ObjectFieldImpl cannot be cast to > org.drools.base.field.ClassFieldImpl > > at > org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772) > > > at > org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87)** > ** > > at > org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109)*** > * > > at > org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130) > > at > org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) > > > at > org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369) > > > at > org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134) > > at > org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) > > > at > org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379) > > > at > org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204) > > at > org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244) > > at > org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330) > > at > org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291) > > at > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882) > > > at > org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180) > > > ... 149 more > > ** ** > > Wrapping the classField != null within an eval appears to be a work around. > > > ** ** > > This is in the suspect method: > > *public* *boolean* evaluate(InternalWorkingMemory workingMemory,** > ** > > *final* InternalReadAccessor extractor,*** > * > > *final* Object object1, *final* FieldValue > object2) { > > Object value1 = extractor.getValue( workingMemory, object1 );* > *** > > Object value2 = object2.getValue(); > > *if* ( value2 == *null* ) { > > ClassFieldImpl classField = (ClassFieldImpl) object2; > > value2 = classField.resolve( workingMemory ); > > } > > *return* *comparator*.equals( value1, value2 ); > > } > > ** ** > > I think the if statement just needs an instanceof check as well or some > other way to track the fact that null may be a valid value to be comparing > with! > > ** ** > > ** ** > > Thomas > > -- > > > ** > This message is confidential and intended only for the addressee. If you > have received this message in error, please immediately notify the > postmas...@nds.com and delete it from your system as well as any copies. > The content of e-mails as well as traffic data may be monitored by NDS for > employment and security purposes. To protect the environment please do not > print this e-mail unless necessary. > > NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 > 4EX, United Kingdom. A company registered in England and Wales. Registered > no. 3080780. VAT no. GB 603 8808 40-00 > > ** > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Regression with Drools 5.3.0-CR1
Note that https://issues.jboss.org/browse/JBRULES-2995 reported against 5.2.0.CR1 and still open might be related. -W 2011/9/26 Edson Tirelli > >Thomas, > >Thanks for reporting. I will look into it. > >Did you open a JIRA yet? Let me know or I will do it otherwise. > >Edson > > 2011/9/26 Swindells, Thomas > >> I’ve just tried upgrading from Drools 5.3.0-CR1 from the beta and I’ve >> hit a regression. >> >> ** ** >> >> JBoss seems to have been down for most of today so I haven’t been able to >> raise a Jira for it. >> >> ** ** >> >> In our model we have Facts which contain fields of java.lang.class, we >> then have a rule which checks that they aren’t null. >> >> Eg >> >> Fact { Class classField} >> >> ** ** >> >> Rule “xyz” >> >> When >> >> Fact(classField != null) >> >> Then >> >> … >> >> End >> >> ** ** >> >> This is giving the following exception >> >> ** ** >> >> Caused by: java.lang.ClassCastException: >> org.drools.base.field.ObjectFieldImpl cannot be cast to >> org.drools.base.field.ClassFieldImpl >> >> at >> org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772) >> >> >> at >> org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87)* >> *** >> >> at >> org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109)** >> ** >> >> at >> org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130) >> >> at >> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) >> >> >> at >> org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369) >> >> >> at >> org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134) >> >> at >> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) >> >> >> at >> org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379) >> >> >> at >> org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204)*** >> * >> >> at >> org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)*** >> * >> >> at >> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330) >> >> at >> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291) >> >> at >> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882) >> >> >> at >> org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180) >> >> >> ... 149 more >> >> ** ** >> >> Wrapping the classField != null within an eval appears to be a work >> around. >> >> ** ** >> >> This is in the suspect method: >> >> *public* *boolean* evaluate(InternalWorkingMemory workingMemory,* >> *** >> >> *final* InternalReadAccessor extractor,** >> ** >> >> *final* Object object1, *final*FieldValue >> object2) { >> >> >> Object value1 = extractor.getValue( workingMemory, object1 ); >> >> >> Object value2 = object2.getValue(); >> >> *if* ( value2 == *null* ) { >> >> ClassFieldImpl classField = (ClassFieldImpl) object2; >> >> value2 = classField.resolve( workingMemory ); >> >> } >> >> *return* *comparator*.equals( value1, value2 ); >> >> } >> >> ** ** >> >> I think the if statement just needs an instanceof check as well or some >> other way to track the fact that null may be a valid value to be comparing >> with! >> >> ** ** >> >> ** ** >> >> Thomas >> >> -- >> >> >> ** >> This message is confidential and intended only for the addressee. If you >> have received this message in error, please immediately notify the >> postmas...@nds.com and delete it from your system as well as any copies. >> The content of e-mails as well as traffic data may be monitored by NDS for >> employment and security purposes. To protect the environment please do not >> print this e-mail unless necessary. >> >> NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 >> 4EX, United Kingdom. A company registered in England and Wales. Registered >> no. 3080780. VAT no. GB 603 8808 40-00 >> >> ** >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https:
Re: [rules-users] Regression with Drools 5.3.0-CR1
Thanks Wolfgang. That is a different issue related to how MVEL deals with class literals. I will check what's the status on it anyway. Edson 2011/9/26 Wolfgang Laun > Note that https://issues.jboss.org/browse/JBRULES-2995 reported against > 5.2.0.CR1 > and still open might be related. > > -W > > 2011/9/26 Edson Tirelli > >> >>Thomas, >> >>Thanks for reporting. I will look into it. >> >>Did you open a JIRA yet? Let me know or I will do it otherwise. >> >>Edson >> >> 2011/9/26 Swindells, Thomas >> >>> I’ve just tried upgrading from Drools 5.3.0-CR1 from the beta and I’ve >>> hit a regression. >>> >>> ** ** >>> >>> JBoss seems to have been down for most of today so I haven’t been able to >>> raise a Jira for it. >>> >>> ** ** >>> >>> In our model we have Facts which contain fields of java.lang.class, we >>> then have a rule which checks that they aren’t null. >>> >>> Eg >>> >>> Fact { Class classField} >>> >>> ** ** >>> >>> Rule “xyz” >>> >>> When >>> >>> Fact(classField != null) >>> >>> Then >>> >>> … >>> >>> End >>> >>> ** ** >>> >>> This is giving the following exception >>> >>> ** ** >>> >>> Caused by: java.lang.ClassCastException: >>> org.drools.base.field.ObjectFieldImpl cannot be cast to >>> org.drools.base.field.ClassFieldImpl >>> >>> at >>> org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772) >>> >>> >>> at >>> org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87) >>> >>> >>> at >>> org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109)* >>> *** >>> >>> at >>> org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130) >>> >>> at >>> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) >>> >>> >>> at >>> org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369) >>> >>> >>> at >>> org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134) >>> >>> at >>> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) >>> >>> >>> at >>> org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379) >>> >>> >>> at >>> org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204)** >>> ** >>> >>> at >>> org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)** >>> ** >>> >>> at >>> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330) >>> >>> at >>> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291) >>> >>> at >>> org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882) >>> >>> >>> at >>> org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180) >>> >>> >>> ... 149 more >>> >>> ** ** >>> >>> Wrapping the classField != null within an eval appears to be a work >>> around. >>> >>> ** ** >>> >>> This is in the suspect method: >>> >>> *public* *boolean* evaluate(InternalWorkingMemory workingMemory, >>> >>> >>> *final* InternalReadAccessor extractor,* >>> *** >>> >>> *final* Object object1, *final*FieldValue >>> object2) { >>> >>> >>> Object value1 = extractor.getValue( workingMemory, object1 ); >>> >>> >>> Object value2 = object2.getValue(); >>> >>> *if* ( value2 == *null* ) { >>> >>> ClassFieldImpl classField = (ClassFieldImpl) object2;*** >>> * >>> >>> value2 = classField.resolve( workingMemory ); >>> >>> } >>> >>> *return* *comparator*.equals( value1, value2 ); >>> >>> } >>> >>> ** ** >>> >>> I think the if statement just needs an instanceof check as well or some >>> other way to track the fact that null may be a valid value to be comparing >>> with! >>> >>> ** ** >>> >>> ** ** >>> >>> Thomas >>> >>> -- >>> >>> >>> ** >>> This message is confidential and intended only for the addressee. If you >>> have received this message in error, please immediately notify the >>> postmas...@nds.com and delete it from your system as well as any copies. >>> The content of e-mails as well as traffic data may be monitored by NDS for >>> employment and security purposes. To protect the environment please do not >>> print this e-mail unless necessary. >>> >>> NDS Limited. Registered Office: One London Ro
Re: [rules-users] Regression with Drools 5.3.0-CR1
Ok, this is fixed: https://issues.jboss.org/browse/JBRULES-3224 I will check JBRULES-2995 now. Edson 2011/9/26 Edson Tirelli > >Thanks Wolfgang. That is a different issue related to how MVEL deals > with class literals. I will check what's the status on it anyway. > >Edson > > > 2011/9/26 Wolfgang Laun > >> Note that https://issues.jboss.org/browse/JBRULES-2995 reported against >> 5.2.0.CR1 >> and still open might be related. >> >> -W >> >> 2011/9/26 Edson Tirelli >> >>> >>>Thomas, >>> >>>Thanks for reporting. I will look into it. >>> >>>Did you open a JIRA yet? Let me know or I will do it otherwise. >>> >>>Edson >>> >>> 2011/9/26 Swindells, Thomas >>> I’ve just tried upgrading from Drools 5.3.0-CR1 from the beta and I’ve hit a regression. ** ** JBoss seems to have been down for most of today so I haven’t been able to raise a Jira for it. ** ** In our model we have Facts which contain fields of java.lang.class, we then have a rule which checks that they aren’t null. Eg Fact { Class classField} ** ** Rule “xyz” When Fact(classField != null) Then … End ** ** This is giving the following exception ** ** Caused by: java.lang.ClassCastException: org.drools.base.field.ObjectFieldImpl cannot be cast to org.drools.base.field.ClassFieldImpl at org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772) at org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87) at org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109) at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130) at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369) at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134) at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379) at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204)* *** at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)* *** at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330) at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882) at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180) ... 149 more ** ** Wrapping the classField != null within an eval appears to be a work around. ** ** This is in the suspect method: *public* *boolean* evaluate(InternalWorkingMemory workingMemory, *final* InternalReadAccessor extractor, *final* Object object1, *final*FieldValue object2) { Object value1 = extractor.getValue( workingMemory, object1 ); Object value2 = object2.getValue(); *if* ( value2 == *null* ) { ClassFieldImpl classField = (ClassFieldImpl) object2;** ** value2 = classField.resolve( workingMemory ); } *return* *comparator*.equals( value1, value2 ); } ** ** I think the if statement just needs an instanceof check as well or some other way to track the fact that null may be a valid value to be comparing with! ** ** ** ** Thomas -- ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the >>
[rules-users] Maven Drools Plugin needs proper de-serialization support from DroolsStreamUtils
Hi all, I think I've found a bug in DroolsStreamUtils. It does not allow to deserialize a collection of KnowledgePackages with dependencies between the packages. In this case, it fails with ClassNotFoundException. Example: Package A contains a type declaration, package B contains a rule using this declaration. Compilation and serialization works fine, but deserialization fails (complains that it cannot find declared type). As it seems, the deserialization code does not consider classes resulting from declared types when resolving type references. This is true for Drools 5.2.0.Final, 5.3.0.CR1 and 5.3.0.Beta1. It works fine for 5.1.1. I was so bold to create a JIRA ticket for this problem right away: https://issues.jboss.org/browse/JBRULES-3225 (with unit tests attached). The functionality provided by class DroolsStreamUtils is essential for the Maven Drools Plugin (compiler needs to serialize stuff, which then needs to be *de-serializable* by applications). If anyone is interested in using the upcoming Maven Drools Plugin to compile rule source code into binary package files and *load* theses packages from your application, please *vote* for this JIRA ticket, as the maven plugin *must* rely on serialization functionality *provided by drools* (a re-implementation is certainly out of scope and would be more than "prone" to incompatibility). Without a fix or at least a workaround for this bug, the maven plugin will only be able to work with Drools 5.1.1 (newer versions are broken, older versions did not include DroolsStreamUtils at all AFAIK). Thanks in advance, to everyone who will contribute to a potential solution or workaround. Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Unsatisfied rule fires - Drools bug?
Hi, I am working with Drools to implement a high-profile rules-engine. I have two rules defined. Clearly, only the first should fire, but both do. Here is my DRL: package com.sample import com.sample.DroolsTest.Request; rule "ExpensiveCanonShopper0" when Request( attributeMap["camera0"] == "canon" && attributeMap["price0"] >= 500 ) then System.out.println("ExpensiveCanonShopper0"); end rule "ExpensiveCanonShopper1" when Request( attributeMap["camera1"] == "canon" && attributeMap["price1"] >= 500 ) then System.out.println("ExpensiveCanonShopper1"); end And the Java class to execute it: public class DroolsTest { @SuppressWarnings({ "rawtypes", "unchecked" }) public static final void main(String[] args) { try { //Loading the Rules System.out.println("Loading rules"); RuleBase ruleBase = readRule(); StatelessSession workingMemory = ruleBase.newStatelessSession(); System.out.println("Firing rules"); Map map = new HashMap(); map.put("camera0", "canon"); map.put("price0", 600); Request request = new Request(); request.setAttributeMap(map); workingMemory.execute(request); } catch (Throwable t) { t.printStackTrace(); } } /** * Please note that this is the “low level” rule assembly API. */ private static RuleBase readRule() throws Exception { //read in the source Reader source = new FileReader(new File("drl", "Generated.drl")); //optionally read in the DSL (if you are using it). //Reader dsl = new InputStreamReader( DroolsTest.class.getResourceAsStream( “/mylang.dsl” ) ); //Use package builder to build up a rule package. //An alternative lower level class called “DrlParser” can also be used… PackageBuilder builder = new PackageBuilder(); //this wil parse and compile in one step //NOTE: There are 2 methods here, the one argument one is for normal DRL. builder.addPackageFromDrl( source ); if (builder.hasErrors()) { PackageBuilderErrors errors = builder.getErrors(); throw new RuntimeException("Error adding package to builder: " + errors.toString()); } //Use the following instead of above if you are using a DSL: //builder.addPackageFromDrl( source, dsl ); //get the compiled package (which is serializable) Package pkg = builder.getPackage(); //add the package to a rulebase (deploy the rule package). RuleBase ruleBase = RuleBaseFactory.newRuleBase(); ruleBase.addPackage( pkg ); return ruleBase; } public static class Request { private Map attributeMap; public Map getAttributeMap() { return attributeMap; } public void setAttributeMap(Map attributeMap) { this.attributeMap = attributeMap; } } } The output is this, meaning both rules fired: Loading rules Firing rules ExpensiveCanonShopper1 ExpensiveCanonShopper0 I have two questions: 1. Is this a bug, or am I doing something wrong? Only "ExpensiveCanonShopper0" should fire. 2. I am pretty sure this is somehow related to the fact that I'm using Map attributes, and not POJO to get "price0" and "camera0". My issue is that I won't know the parameters in advance (they are coming in a URL), so I can't pre-declare them, and thus need something dynamic like a Map. Is this how Drools is intended to be used? The documentation appears very POJO-centric. I am using Drools 5.2 Thank you! -Matt -- View this message in context: http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp3370653p3370653.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users