[rules-users] Object insertion on runtime
Hi all, Since yesterday, I am having a problem with reading inserted objects from memory. I don't know why it does not go as planned, because it should be quite straightforward. It is getting boring to stare at the code, so maybe one of you can detect an error. There are 2 kinds of rules. One kind inserts price objects into working memory (as in example 1). THe other kind detects whether the price exists and adapts it to a product (as in example 2). Example 1 seems to work, but the engine does not seem to recognize them as a Price object. All original price attributes of the products remain unchanged unless: - I manually insert a Prce object before calling fireAllRules() or - Checking for an existing price is commented out in the LHS Removing constraints from $price (just checking for existance of a price) does not help. Any idea what has been going wrong? Thanks in advance. ==Example 1= rule Prices_17 lock-on-active true when then Price $price = new Price(); $price.setName(Blue autumn); $price.setPrice(6); insert($price); System.out.println(Price + $price.getName() + inserted); end =Example of usage= rule Products_36 lock-on-active true when $product: Product(colour == Blue) Season(season == Season.AUTUMN) $price: Price(name == Blue autumn) then $product.setPrice($price.getPrice()); update($product); System.out.println(Rule executed); end === -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Object-insertion-on-runtime-tp2650219p2650219.html Sent from the Drools - User 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] Object insertion on runtime
I suspect your use of lock-on-active. Expert's documentation states: Whenever ... an agenda-group receives the focus, any rule within that group that has lock-on-active set to true will not be activated any more; irrespective of the origin of the update, the activation of a matching rule is discarded. Both rules are in the default MAIN agenda group so when the first inserts a new Price the update to WM (insert in your case) is not visible to the other rule. Inserting a new Price before calling fireAllRules or commenting out the price constraint in the LHS alters the Facts\Patterns needing to be matched for activation to occur. So, try removing lock-on-active (or making the two rules in different agenda groups). With kind regards, Mike On 8 March 2011 09:53, FrankVhh frank.vanhoensho...@agserv.eu wrote: Hi all, Since yesterday, I am having a problem with reading inserted objects from memory. I don't know why it does not go as planned, because it should be quite straightforward. It is getting boring to stare at the code, so maybe one of you can detect an error. There are 2 kinds of rules. One kind inserts price objects into working memory (as in example 1). THe other kind detects whether the price exists and adapts it to a product (as in example 2). Example 1 seems to work, but the engine does not seem to recognize them as a Price object. All original price attributes of the products remain unchanged unless: - I manually insert a Prce object before calling fireAllRules() or - Checking for an existing price is commented out in the LHS Removing constraints from $price (just checking for existance of a price) does not help. Any idea what has been going wrong? Thanks in advance. ==Example 1= rule Prices_17 lock-on-active true when then Price $price = new Price(); $price.setName(Blue autumn); $price.setPrice(6); insert($price); System.out.println(Price + $price.getName() + inserted); end =Example of usage= rule Products_36 lock-on-active true when $product: Product(colour == Blue) Season(season == Season.AUTUMN) $price: Price(name == Blue autumn) then $product.setPrice($price.getPrice()); update($product); System.out.println(Rule executed); end === -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Object-insertion-on-runtime-tp2650219p2650219.html Sent from the Drools - User 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] Object insertion on runtime
I know etiquette stipulates to avoid small talk, but since there is no resolved button, I think this can be useful. You suspected rightly, manstis, removing lock-on-active and replacing it with extra constraints in the LHS indeed solved the problem. Thanks for the quick (and correct) response :-). manstis wrote: I suspect your use of lock-on-active. Expert's documentation states: Whenever ... an agenda-group receives the focus, any rule within that group that has lock-on-active set to true will not be activated any more; irrespective of the origin of the update, the activation of a matching rule is discarded. Both rules are in the default MAIN agenda group so when the first inserts a new Price the update to WM (insert in your case) is not visible to the other rule. Inserting a new Price before calling fireAllRules or commenting out the price constraint in the LHS alters the Facts\Patterns needing to be matched for activation to occur. So, try removing lock-on-active (or making the two rules in different agenda groups). With kind regards, Mike On 8 March 2011 09:53, FrankVhh wrote: Hi all, Since yesterday, I am having a problem with reading inserted objects from memory. I don't know why it does not go as planned, because it should be quite straightforward. It is getting boring to stare at the code, so maybe one of you can detect an error. There are 2 kinds of rules. One kind inserts price objects into working memory (as in example 1). THe other kind detects whether the price exists and adapts it to a product (as in example 2). Example 1 seems to work, but the engine does not seem to recognize them as a Price object. All original price attributes of the products remain unchanged unless: - I manually insert a Prce object before calling fireAllRules() or - Checking for an existing price is commented out in the LHS Removing constraints from $price (just checking for existance of a price) does not help. Any idea what has been going wrong? Thanks in advance. ==Example 1= rule Prices_17 lock-on-active true when then Price $price = new Price(); $price.setName(Blue autumn); $price.setPrice(6); insert($price); System.out.println(Price + $price.getName() + inserted); end =Example of usage= rule Products_36 lock-on-active true when $product: Product(colour == Blue) Season(season == Season.AUTUMN) $price: Price(name == Blue autumn) then $product.setPrice($price.getPrice()); update($product); System.out.println(Rule executed); end === -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Object-insertion-on-runtime-tp2650219p2650219.html Sent from the Drools - User 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 -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Object-insertion-on-runtime-tp2650219p2650454.html Sent from the Drools - User 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] Object insertion on runtime
Hi Frank, It's good to have feedback :) Closing the loop will help others who Google for similar issues at some future date. At least you no longer have to stare at your code getting bored! With kind regards, Mike On 8 March 2011 11:31, FrankVhh frank.vanhoensho...@agserv.eu wrote: I know etiquette stipulates to avoid small talk, but since there is no resolved button, I think this can be useful. You suspected rightly, manstis, removing lock-on-active and replacing it with extra constraints in the LHS indeed solved the problem. Thanks for the quick (and correct) response :-). manstis wrote: I suspect your use of lock-on-active. Expert's documentation states: Whenever ... an agenda-group receives the focus, any rule within that group that has lock-on-active set to true will not be activated any more; irrespective of the origin of the update, the activation of a matching rule is discarded. Both rules are in the default MAIN agenda group so when the first inserts a new Price the update to WM (insert in your case) is not visible to the other rule. Inserting a new Price before calling fireAllRules or commenting out the price constraint in the LHS alters the Facts\Patterns needing to be matched for activation to occur. So, try removing lock-on-active (or making the two rules in different agenda groups). With kind regards, Mike On 8 March 2011 09:53, FrankVhh wrote: Hi all, Since yesterday, I am having a problem with reading inserted objects from memory. I don't know why it does not go as planned, because it should be quite straightforward. It is getting boring to stare at the code, so maybe one of you can detect an error. There are 2 kinds of rules. One kind inserts price objects into working memory (as in example 1). THe other kind detects whether the price exists and adapts it to a product (as in example 2). Example 1 seems to work, but the engine does not seem to recognize them as a Price object. All original price attributes of the products remain unchanged unless: - I manually insert a Prce object before calling fireAllRules() or - Checking for an existing price is commented out in the LHS Removing constraints from $price (just checking for existance of a price) does not help. Any idea what has been going wrong? Thanks in advance. ==Example 1= rule Prices_17 lock-on-active true when then Price $price = new Price(); $price.setName(Blue autumn); $price.setPrice(6); insert($price); System.out.println(Price + $price.getName() + inserted); end =Example of usage= rule Products_36 lock-on-active true when $product: Product(colour == Blue) Season(season == Season.AUTUMN) $price: Price(name == Blue autumn) then $product.setPrice($price.getPrice()); update($product); System.out.println(Rule executed); end === -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Object-insertion-on-runtime-tp2650219p2650219.html Sent from the Drools - User 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 -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Object-insertion-on-runtime-tp2650219p2650454.html Sent from the Drools - User 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
[rules-users] (no subject)
I am new to drools and I would like to download the binaries and try some of the examples. However, when I click on the download like of the Drools binaries the screen goes dim and nothing happens. Would someone please explain to me what is going on and what I should do to get the binaries? I did what Faisal Shafique suggested yesterday, so I have tried multiple browsers from home and from work. I have tried IE 8 and Firefox 3.6.15 and nothing seems to work. Is there another way to get the binaries like using ftp? Anyone have any ideas what I can do next to get a copy of the binaries short of building the binaries? ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] (no subject)
Please retry - I think the update happened 10mins ago. Working for me now. -W 2011/3/8 Billy Buzzard billy.buzz...@bnsflogistics.com I am new to drools and I would like to download the binaries and try some of the examples. However, when I click on the download like of the Drools binaries the screen goes dim and nothing happens. Would someone please explain to me what is going on and what I should do to get the binaries? I did what Faisal Shafique suggested yesterday, so I have tried multiple browsers from home and from work. I have tried IE 8 and Firefox 3.6.15 and nothing seems to work. Is there another way to get the binaries like using ftp? Anyone have any ideas what I can do next to get a copy of the binaries short of building the binaries? ___ 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] (no subject)
right clic on it and save link as? 2011/3/8 Billy Buzzard billy.buzz...@bnsflogistics.com I am new to drools and I would like to download the binaries and try some of the examples. However, when I click on the download like of the Drools binaries the screen goes dim and nothing happens. Would someone please explain to me what is going on and what I should do to get the binaries? I did what Faisal Shafique suggested yesterday, so I have tried multiple browsers from home and from work. I have tried IE 8 and Firefox 3.6.15 and nothing seems to work. Is there another way to get the binaries like using ftp? Anyone have any ideas what I can do next to get a copy of the binaries short of building the binaries? ___ 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] Can not download Drools binaries
Just got a mail saying that it's resolved and I 've verified it: http://www.jboss.org/drools/downloads Op 07-03-11 16:01, Wolfgang Laun schreef: It's being looked into and hopefully resolved soon: https://issues.jboss.org/browse/ORG-990 -W 2011/3/7 Faisal Shafique just_fai...@yahoo.com mailto:just_fai...@yahoo.com That happened to me recently too. Using Internet Explorer browser instead of Chrome fixed it. Try downloading through a different browser. Regards, Faisal Shafique On Mar 7, 2011, at 6:55 AM, Billy Buzzard billy.buzz...@bnsflogistics.com mailto:billy.buzz...@bnsflogistics.com wrote: I’m new to drools and I would like to download the binaries and try some of the examples. However, when I click on the download like of the Drools binaries the screen goes dim and nothing happens. Would someone please explain to me what is going on and what I should do to get the binaries. ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org mailto: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 -- With kind regards, Geoffrey De Smet ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] (no subject)
A left click is OK, too; then continue download. -W 2011/3/8 Eddy Hautot eddyhau...@gmail.com right clic on it and save link as? 2011/3/8 Billy Buzzard billy.buzz...@bnsflogistics.com I am new to drools and I would like to download the binaries and try some of the examples. However, when I click on the download like of the Drools binaries the screen goes dim and nothing happens. Would someone please explain to me what is going on and what I should do to get the binaries? I did what Faisal Shafique suggested yesterday, so I have tried multiple browsers from home and from work. I have tried IE 8 and Firefox 3.6.15 and nothing seems to work. Is there another way to get the binaries like using ftp? Anyone have any ideas what I can do next to get a copy of the binaries short of building the binaries? ___ 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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] (no subject)
i said that because i had the exact same problem these last 2 days. had to do a right clic and save link as. Now it's reworking with left clic/continue download :-) 2011/3/8 Wolfgang Laun wolfgang.l...@gmail.com A left click is OK, too; then continue download. -W 2011/3/8 Eddy Hautot eddyhau...@gmail.com right clic on it and save link as? 2011/3/8 Billy Buzzard billy.buzz...@bnsflogistics.com I am new to drools and I would like to download the binaries and try some of the examples. However, when I click on the download like of the Drools binaries the screen goes dim and nothing happens. Would someone please explain to me what is going on and what I should do to get the binaries? I did what Faisal Shafique suggested yesterday, so I have tried multiple browsers from home and from work. I have tried IE 8 and Firefox 3.6.15 and nothing seems to work. Is there another way to get the binaries like using ftp? Anyone have any ideas what I can do next to get a copy of the binaries short of building the binaries? ___ 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 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] Guvnor and drools implementation - questions
Hi Vincent, Thanks for precisions. Didn't knew only set/get are used. Get to be careful when i will have 100+ attributes :-) Yes i created rueles with guided editor and it's working with my attribute. is there a way to remove empty, entrySet, keySet, clone,... herited from Map. So i would have only the attribute i have defined? Ok i will do like this for testing eval($m1 != $m2) ... i have put this in separate line to meke it clearer at the beginning. I think i will do your first option, rules will be clearer. i have always used drl file instead of package. If i deploy a file.pkg, is there a way to know what's in it? If i deploy something, i just want to be able later to very that all is well what i think if i have a doubt (easy with drl file). When i try to create my session i have problem with pkg. For know with .drl file i do with that : KnowledgeBase knowledgeBase = createKnowledgeBase(); StatefulKnowledgeSession session = knowledgeBase.newStatefulKnowledgeSession(); private static KnowledgeBase createKnowledgeBase() { final KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder (); builder.add(ResourceFactory.newUrlResource(file:///d://basicRule.drl), ResourceType.DRL); if (builder.hasErrors()) { throw new RuntimeException(builder.getErrors() .toString()); } KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(); knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages()); return knowledgeBase; } If i replace the line : builder.add(ResourceFactory.newUrlResource(file:///d://basicRule.drl), ResourceType.DRL); by : builder.add(ResourceFactory.newUrlResource(file:///d://PackageTest1.pkg), ResourceType.PKG); but it's crashing : xception in thread main org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule.builder.dialect.java.JavaDialectConfiguration' at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:283) at org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:268) at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:181) at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:154) at org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactoryServiceImpl.java:26) at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactory.java:86) at TestMapPojoPackage.createKnowledgeBase(TestMapPojoPackage.java:86) at TestMapPojoPackage.main(TestMapPojoPackage.java:58) Caused by: java.lang.RuntimeException: The Janino jar is not in the classpath at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:100) at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:55) at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:279) ... 7 more Is it something special to do? Thanks again for your time On Mon, Mar 7, 2011 at 7:44 PM, Vincent Legendre [via Drools - Java Rules Engine] ml-node+2647352-436278430-237...@n3.nabble.com wrote: html head /head body text=#00 bgcolor=#ff I've just created 2 class like you show me with some changes to fit and test all (timestamp are long in fact, i have put int, double and string as well) In the second class you don't need the attributes as members, because Drools uses get / set methods to deduce them, and anyway you never use them as they are stored in the map. Then i have imported this in Guvnor. I have made 2 categories. I have put the model (jar) in the 2 categories. That is non-sense. Jars are not linked to a category but to a package. I have created 2 simple rules playing with the attributes id, timestamp... With Guided editor ? 1) For the condition Map $m1 different then Map $m2. I suppose i have to use the function define in MapPojo? I have to write it by hand using free from drl : eval($m1 != $m2) ? or is there a better way? Its a way. You can also test the id directly in conditions (in Guided editor, bind the id of the first instance to a var, then compare it in the second condition. The same for testing that $m1 timestamp (Long) is befor $m2. I have to write it by hand : eval($m1.isBefore($m2))? So they have to know it exist a method isBefore if not said by the gui? Same. Add the test directly in the condition. Another solution is to use a custom operator (search this mailing list for samples). 2) In the code It's written MapTest1(..) instead of Map(...) so i suppose drools has to do it with the precompiled package .pkg to know about the MapPojo and MapTest1..
Re: [rules-users] Guvnor and drools implementation - questions
it's working for pkg, bad library On Tue, Mar 8, 2011 at 4:30 PM, Eddy Hautot eddyhau...@gmail.com wrote: Hi Vincent, Thanks for precisions. Didn't knew only set/get are used. Get to be careful when i will have 100+ attributes :-) Yes i created rueles with guided editor and it's working with my attribute. is there a way to remove empty, entrySet, keySet, clone,... herited from Map. So i would have only the attribute i have defined? Ok i will do like this for testing eval($m1 != $m2) ... i have put this in separate line to meke it clearer at the beginning. I think i will do your first option, rules will be clearer. i have always used drl file instead of package. If i deploy a file.pkg, is there a way to know what's in it? If i deploy something, i just want to be able later to very that all is well what i think if i have a doubt (easy with drl file). When i try to create my session i have problem with pkg. For know with .drl file i do with that : KnowledgeBase knowledgeBase = createKnowledgeBase(); StatefulKnowledgeSession session = knowledgeBase.newStatefulKnowledgeSession(); private static KnowledgeBase createKnowledgeBase() { final KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder (); builder.add(ResourceFactory.newUrlResource(file:///d://basicRule.drl), ResourceType.DRL); if (builder.hasErrors()) { throw new RuntimeException(builder.getErrors() .toString()); } KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(); knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages()); return knowledgeBase; } If i replace the line : builder.add(ResourceFactory.newUrlResource(file:///d://basicRule.drl), ResourceType.DRL); by : builder.add(ResourceFactory.newUrlResource(file:///d://PackageTest1.pkg), ResourceType.PKG); but it's crashing : xception in thread main org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule.builder.dialect.java.JavaDialectConfiguration' at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:283) at org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:268) at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:181) at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:154) at org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactoryServiceImpl.java:26) at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactory.java:86) at TestMapPojoPackage.createKnowledgeBase(TestMapPojoPackage.java:86) at TestMapPojoPackage.main(TestMapPojoPackage.java:58) Caused by: java.lang.RuntimeException: The Janino jar is not in the classpath at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:100) at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:55) at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:279) ... 7 more Is it something special to do? Thanks again for your time On Mon, Mar 7, 2011 at 7:44 PM, Vincent Legendre [via Drools - Java Rules Engine] ml-node+2647352-436278430-237...@n3.nabble.com wrote: html head /head body text=#00 bgcolor=#ff I've just created 2 class like you show me with some changes to fit and test all (timestamp are long in fact, i have put int, double and string as well) In the second class you don't need the attributes as members, because Drools uses get / set methods to deduce them, and anyway you never use them as they are stored in the map. Then i have imported this in Guvnor. I have made 2 categories. I have put the model (jar) in the 2 categories. That is non-sense. Jars are not linked to a category but to a package. I have created 2 simple rules playing with the attributes id, timestamp... With Guided editor ? 1) For the condition Map $m1 different then Map $m2. I suppose i have to use the function define in MapPojo? I have to write it by hand using free from drl : eval($m1 != $m2) ? or is there a better way? Its a way. You can also test the id directly in conditions (in Guided editor, bind the id of the first instance to a var, then compare it in the second condition. The same for testing that $m1 timestamp (Long) is befor $m2. I have to write it by hand : eval($m1.isBefore($m2))? So they have to know it exist a method isBefore if not said by the gui? Same. Add the test directly in the condition. Another solution is to use a custom operator (search this mailing list for
[rules-users] Best approach for handling parallel requests for a stateful rules session
We've been over multiple ways of handling multiple parallel requests for a stateful rules session and I want to make sure the approach we have settled on makes sense. We will be getting multiple requests at a time to run some score calculation rules for various products. In the past we used stateless rules sessions to do this and it worked fine. In the newer version of our application we are using significantly more data to do our calculation and are pretty sure stateful is the way to go. That being said, can we use the same session in multiple threads? Based on our understanding, a session isn't inherently thread safe, so we are thinking we will need to do one of two things: 1. Synchronize all updates to facts and the calling of fireAllRules so that only one thread is doing this at a time. Is this the best (or only safe) approach in this situation? Since all fact updates and rules running in done in one thread, when is throughput a concern (obviously depends on hardware, # of rules, # of facts, etc)? 2. Ensure that only one thread updates the facts related to a given product at a time. Multiple threads could still call fireAllRules at the same time, but after the rules finish, the calling class would grab the facts that would have been updated for just the product that it's interested in. That way, it doesn't matter if the rules were technically matched in a different thread, as long as I'm grabbing just the data I'm interested in. Is this a safe approach? Does it end up offering more throughput capability than approach #1? Josh -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Best-approach-for-handling-parallel-requests-for-a-stateful-rules-session-tp2651617p2651617.html Sent from the Drools - User 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] Process instance status not completing when using JPA.
More info... This behavior is reproducible in the Drools JPA test cases. In org.drools.persistence.session.PersistentStatefulSessionTest.testPersistenceState() and testPersistenceRuleSet(), if you add a breakpoint before loading the processInstance the last time (when it is null because the process has completed), you can see that processInstance.getState() returns 1 (ACTIVE) instead of 2 (COMPLETE). I added the ConsoleLogger to the ksession and can see the AFTER RULEFLOW COMPLETED log message. In the other test cases, the state is correctly set to 2 after the process completes. On Mon, Mar 7, 2011 at 11:21 AM, Dan Nathanson d...@ddnconsulting.comwrote: Hi, I'm seeing some odd behavior in Drools Flow 5.1.1. When using JPA and creating a StatefulKnowledgeSession using JPAKnowledgeService.newStatefulKnowledgeSession(), processes look like they run to completion, but calling RuleFlowProcessInstance.getState() on process instances created froim this knowledge session returns 1 (STATE_ACTIVE). Calling getActiveNodeIds() throws a NullPointerException. If I get a StatefulKnowledgeSession without JPA by calling KnowledgeBase.newStatefulKnowledgeSession(), getState() returns 2 (STATE_COMPLETED). I added KnowledgeRuntimeLoggerFactory.newConsoleLogger(knowledgeSession) and can see in both cases that the process is complete. Has this been seen before? Is it a known bug? Am I doing something wrong? Regards, Dan Nathanson ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Best approach for handling parallel requests for a stateful rules session
Take a look at the org.drools.StatefulSession.async*() methods. I've used them in a multithreaded context before. --- On Tue, 3/8/11, jkrupka jkru...@gmail.com wrote: From: jkrupka jkru...@gmail.com Subject: [rules-users] Best approach for handling parallel requests for a stateful rules session To: rules-users@lists.jboss.org Date: Tuesday, March 8, 2011, 11:10 AM We've been over multiple ways of handling multiple parallel requests for a stateful rules session and I want to make sure the approach we have settled on makes sense. We will be getting multiple requests at a time to run some score calculation rules for various products. In the past we used stateless rules sessions to do this and it worked fine. In the newer version of our application we are using significantly more data to do our calculation and are pretty sure stateful is the way to go. That being said, can we use the same session in multiple threads? Based on our understanding, a session isn't inherently thread safe, so we are thinking we will need to do one of two things: 1. Synchronize all updates to facts and the calling of fireAllRules so that only one thread is doing this at a time. Is this the best (or only safe) approach in this situation? Since all fact updates and rules running in done in one thread, when is throughput a concern (obviously depends on hardware, # of rules, # of facts, etc)? 2. Ensure that only one thread updates the facts related to a given product at a time. Multiple threads could still call fireAllRules at the same time, but after the rules finish, the calling class would grab the facts that would have been updated for just the product that it's interested in. That way, it doesn't matter if the rules were technically matched in a different thread, as long as I'm grabbing just the data I'm interested in. Is this a safe approach? Does it end up offering more throughput capability than approach #1? Josh -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Best-approach-for-handling-parallel-requests-for-a-stateful-rules-session-tp2651617p2651617.html Sent from the Drools - User 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] Best approach for handling parallel requests for a stateful rules session
Took a look... thanks. I'm not sure that they will help me though - do the async methods actually look to see if fireAllRules is already running somewhere else and synchronize the calls? Or do they just wrap a Callable around it so that if your rules take a long time to run you can do something else while they run? -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Best-approach-for-handling-parallel-requests-for-a-stateful-rules-session-tp2651617p2652011.html Sent from the Drools - User 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 Logging
Thanks! I could get the facts by adding a WorkingMemoryEventListener but I'm more interested in generating a XML file similar to the one generated by KnowledgeLoggerFactory. Any idea if that is possible by passing a Logger object instead of a file name? -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Logging-tp2647772p2652058.html Sent from the Drools - User 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] Best approach for handling parallel requests for a stateful rules session
They submit the commands to an execution queue, and they're executed in the order received in a thread safe manner. And note there's an asyncFireAllRules() method, so you can time when rules fire. As for whether objects are fed into working memory while rules are firing, I'm not sure, but that would be easy to test. (Just create rules that cause an infinite loop with low salience, start them up, and try to insert more data that trigger rules of a higher salience.) Or maybe a dev will reply with a conclusive answer. :) --- On Tue, 3/8/11, jkrupka jkru...@gmail.com wrote: From: jkrupka jkru...@gmail.com Subject: Re: [rules-users] Best approach for handling parallel requests for a stateful rules session To: rules-users@lists.jboss.org Date: Tuesday, March 8, 2011, 12:42 PM Took a look... thanks. I'm not sure that they will help me though - do the async methods actually look to see if fireAllRules is already running somewhere else and synchronize the calls? Or do they just wrap a Callable around it so that if your rules take a long time to run you can do something else while they run? -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Best-approach-for-handling-parallel-requests-for-a-stateful-rules-session-tp2651617p2652011.html Sent from the Drools - User 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] work definition conf file - parameter mapping
Nevermind. I get it now :) -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/work-definition-conf-file-parameter-mapping-tp2652643p2652875.html Sent from the Drools - User 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] Guvnor and drools implementation - questions
Yes i created rueles with guided editor and it's working with my attribute. is there a way to remove empty, entrySet, keySet, clone,... herited from Map. So i would have only the attribute i have defined? Don't make the POJO extends Map, but containing a map. i have always used drl file instead of package. If i deploy a file.pkg, is there a way to know what's in it? If i deploy something, i just want to be able later to very that all is well what i think if i have a doubt (easy with drl file). try this (the only trick is to compact the rules that comes from a decision table into one main log line) : public static void dumpKbContent(KnowledgeBase knowledgeBase) { System.out.println( + ruleSet + ); // Dump content for (KnowledgePackage p : knowledgeBase.getKnowledgePackages()) { System.out.println(-o0o- Package + p.getName() + -o0o-); System.out.println(Processes : ); for (Process flow : p.getProcesses()) { System.out.println( - + flow.getName()); } System.out.println(Rules : ); String lastRuleName = ; for (Rule rule : p.getRules()) { String ruleName = extractMainTableName(rule.getName()); if (!ruleName.equals(lastRuleName)) { System.out.println( - + ruleName); lastRuleName = ruleName; } } System.out.println(-o0o- End Package + p.getName() + -o0o-); } System.out.println( END + ruleSet + ); } private static String extractMainTableName(String ruleName) { // tables Pattern p = Pattern.compile((.*)_[0-9]+); Matcher m = p.matcher(ruleName); if (m.matches()) { return m.group(1) + ... table; } else { return ruleName; } } ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Misunderstanding salience?
Hi There I'm new to drools. I've just set up the Drools-Server and it is (finally!) working and serving my test rule-set. The one thing that's not working as I expect it is the rule ordering via salience. This is my simple test rule set: rule General brain eating advice when p : Patient(eatsBrains == true) then p.setAdvice(Stop eating brains, or at least, try to cut down); end rule Zombie exception to brain eating advice salience -50 when p : Patient(eatsBrains == true, isZombie == true) then p.setAdvice(Evidence suggests that the undead cannot contract Kuru or that the effects are irellevant given the + patient's current zombified state.\nSuggest euthenasing patient lest he/she eat your (or someone + else's) brains); end The idea is that the first rule fires all the time unless the patient happens to be a zombie, in which case the exception rule (the second rule) kicks in. Now, as I have it here, with the exception at salience at -50 it actually works, which is the opposite of what I was expecting. I'd thought that I would have had to have the exception at a higher salience to fire first. That was what I tried first but that didn't work - everyone got the general advice, zombies included. What am I misunderstanding here? Thanks! Peter. --- It is very difficult to get a man to understand something when his tribal identity depends on his not understanding it - Michael Bérubé on Republican climate change denial. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Process instance status not completing when using JPA.
Dan, Once you start using persistence, you should know that the process instance you are retrieving is no longer the internal process instance but a version of the process instance at the moment you requested it. This process instance however is disconnected, meaning that it will not automatically update when the internal process instance changes. The main reason is that, when using persistence, process instances can be removed and reloaded from database at any time, so you basically get a copy. If you register a listener that listens for process instance completion right before inserting the list in testPersistenceState(), you will notice that this process instance gets completed and that the process instance state of the internal process instance is set to completed. The copy you still have from before still is in active state though. Since process instances that are completed are also removed from persistence as no longer necessary, you can't get the process instance in state completed. That's why we test whether a process instance is completed by checking it is null when we try to retrieve it. Another option would be to use a history logger of course. Kris Dan Nathanson wrote: More info... This behavior is reproducible in the Drools JPA test cases. In org.drools.persistence.session.PersistentStatefulSessionTest.testPersistenceState() and testPersistenceRuleSet(), if you add a breakpoint before loading the processInstance the last time (when it is null because the process has completed), you can see that processInstance.getState() returns 1 (ACTIVE) instead of 2 (COMPLETE). I added the ConsoleLogger to the ksession and can see the AFTER RULEFLOW COMPLETED log message. In the other test cases, the state is correctly set to 2 after the process completes. On Mon, Mar 7, 2011 at 11:21 AM, Dan Nathanson d...@ddnconsulting.com mailto:d...@ddnconsulting.com wrote: Hi, I'm seeing some odd behavior in Drools Flow 5.1.1. When using JPA and creating a StatefulKnowledgeSession using JPAKnowledgeService.newStatefulKnowledgeSession(), processes look like they run to completion, but calling RuleFlowProcessInstance.getState() on process instances created froim this knowledge session returns 1 (STATE_ACTIVE). Calling getActiveNodeIds() throws a NullPointerException. If I get a StatefulKnowledgeSession without JPA by calling KnowledgeBase.newStatefulKnowledgeSession(), getState() returns 2 (STATE_COMPLETED). I added KnowledgeRuntimeLoggerFactory.newConsoleLogger(knowledgeSession) and can see in both cases that the process is complete. Has this been seen before? Is it a known bug? Am I doing something wrong? Regards, Dan Nathanson ___ 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] Process instance status not completing when using JPA.
Thanks for the reply, Kris. I figured it might be something like that, but was thrown because one of the test cases in PersistentStatefulSessionTest (testPersistenceWorkItems3) does check for process state COMPLETE. I worked around the issue by adding a ProcessEventListener that implements the afterProcessComplete() method. Since my action upon process completion is to send a JMS message to the person who started the process, using an event listener is actually a little bit cleaner than checking process status after every session state change. Regards, Dan Nathanson On Tue, Mar 8, 2011 at 5:19 PM, Kris Verlaenen kris.verlae...@cs.kuleuven.be wrote: Dan, Once you start using persistence, you should know that the process instance you are retrieving is no longer the internal process instance but a version of the process instance at the moment you requested it. This process instance however is disconnected, meaning that it will not automatically update when the internal process instance changes. The main reason is that, when using persistence, process instances can be removed and reloaded from database at any time, so you basically get a copy. If you register a listener that listens for process instance completion right before inserting the list in testPersistenceState(), you will notice that this process instance gets completed and that the process instance state of the internal process instance is set to completed. The copy you still have from before still is in active state though. Since process instances that are completed are also removed from persistence as no longer necessary, you can't get the process instance in state completed. That's why we test whether a process instance is completed by checking it is null when we try to retrieve it. Another option would be to use a history logger of course. Kris Dan Nathanson wrote: More info... This behavior is reproducible in the Drools JPA test cases. In org.drools.persistence.session.PersistentStatefulSessionTest.testPersistenceState() and testPersistenceRuleSet(), if you add a breakpoint before loading the processInstance the last time (when it is null because the process has completed), you can see that processInstance.getState() returns 1 (ACTIVE) instead of 2 (COMPLETE). I added the ConsoleLogger to the ksession and can see the AFTER RULEFLOW COMPLETED log message. In the other test cases, the state is correctly set to 2 after the process completes. On Mon, Mar 7, 2011 at 11:21 AM, Dan Nathanson d...@ddnconsulting.com mailto:d...@ddnconsulting.com wrote: Hi, I'm seeing some odd behavior in Drools Flow 5.1.1. When using JPA and creating a StatefulKnowledgeSession using JPAKnowledgeService.newStatefulKnowledgeSession(), processes look like they run to completion, but calling RuleFlowProcessInstance.getState() on process instances created froim this knowledge session returns 1 (STATE_ACTIVE). Calling getActiveNodeIds() throws a NullPointerException. If I get a StatefulKnowledgeSession without JPA by calling KnowledgeBase.newStatefulKnowledgeSession(), getState() returns 2 (STATE_COMPLETED). I added KnowledgeRuntimeLoggerFactory.newConsoleLogger(knowledgeSession) and can see in both cases that the process is complete. Has this been seen before? Is it a known bug? Am I doing something wrong? Regards, Dan Nathanson ___ 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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Misunderstanding salience?
Actually, I think I've figured this one out : in the Zombie case, it's firing both rules and it's just that with the negative salience, the zombie exception rule is the last rule fired, therefore, the last thing written into advice. So... what would be the correct way to do what I'm trying to do here? The idea is that the Zombie exception rule should fire in preference to the general rule and that none of the general processing should occur at all (imaging that these rules had side-effects for the rest of the system they're attached to, we don't want all the general rule side effects to apply and then all the exception case side effects) Thanks in advance! Peter. From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Peter Ashford Sent: Wednesday, 9 March 2011 1:31 p.m. To: rules-users@lists.jboss.org Subject: [rules-users] Misunderstanding salience? Hi There I'm new to drools. I've just set up the Drools-Server and it is (finally!) working and serving my test rule-set. The one thing that's not working as I expect it is the rule ordering via salience. This is my simple test rule set: rule General brain eating advice when p : Patient(eatsBrains == true) then p.setAdvice(Stop eating brains, or at least, try to cut down); end rule Zombie exception to brain eating advice salience -50 when p : Patient(eatsBrains == true, isZombie == true) then p.setAdvice(Evidence suggests that the undead cannot contract Kuru or that the effects are irellevant given the + patient's current zombified state.\nSuggest euthenasing patient lest he/she eat your (or someone + else's) brains); end The idea is that the first rule fires all the time unless the patient happens to be a zombie, in which case the exception rule (the second rule) kicks in. Now, as I have it here, with the exception at salience at -50 it actually works, which is the opposite of what I was expecting. I'd thought that I would have had to have the exception at a higher salience to fire first. That was what I tried first but that didn't work - everyone got the general advice, zombies included. What am I misunderstanding here? Thanks! Peter. --- It is very difficult to get a man to understand something when his tribal identity depends on his not understanding it - Michael Bérubé on Republican climate change denial. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Misunderstanding salience?
Peter, The EXACT way to accomplish the functionality that you are looking for is activation-group; if two rules are in the same activation group, only one of them will fire. Note that the rule with HIGHER salience will fire first; to accomplish what you are looking for you'd have to give the exception rule a higher salience. I would also note that although there are specific instances where activation-group has a strong need, many in the community find that the most power and flexibility from the rule engine comes from letting go of trying to exactly order your rule execution, and instead letting the rule engine decide what would happen here. One way to accomplish this in your case would be to simply add (isZombie == false) to your constraint on the general rule. Another way that involves salience but NOT agenda groups is to set a high salience on your exception rule, but only add advice if advice is null. The possibilities are endless. With kind regards, David Faulkner david.faulk...@amentra.com From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Peter Ashford Sent: Wednesday, March 09, 2011 7:24 AM To: Rules Users List Subject: Re: [rules-users] Misunderstanding salience? Actually, I think I've figured this one out : in the Zombie case, it's firing both rules and it's just that with the negative salience, the zombie exception rule is the last rule fired, therefore, the last thing written into advice. So... what would be the correct way to do what I'm trying to do here? The idea is that the Zombie exception rule should fire in preference to the general rule and that none of the general processing should occur at all (imaging that these rules had side-effects for the rest of the system they're attached to, we don't want all the general rule side effects to apply and then all the exception case side effects) Thanks in advance! Peter. From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Peter Ashford Sent: Wednesday, 9 March 2011 1:31 p.m. To: rules-users@lists.jboss.org Subject: [rules-users] Misunderstanding salience? Hi There I'm new to drools. I've just set up the Drools-Server and it is (finally!) working and serving my test rule-set. The one thing that's not working as I expect it is the rule ordering via salience. This is my simple test rule set: rule General brain eating advice when p : Patient(eatsBrains == true) then p.setAdvice(Stop eating brains, or at least, try to cut down); end rule Zombie exception to brain eating advice salience -50 when p : Patient(eatsBrains == true, isZombie == true) then p.setAdvice(Evidence suggests that the undead cannot contract Kuru or that the effects are irellevant given the + patient's current zombified state.\nSuggest euthenasing patient lest he/she eat your (or someone + else's) brains); end The idea is that the first rule fires all the time unless the patient happens to be a zombie, in which case the exception rule (the second rule) kicks in. Now, as I have it here, with the exception at salience at -50 it actually works, which is the opposite of what I was expecting. I'd thought that I would have had to have the exception at a higher salience to fire first. That was what I tried first but that didn't work - everyone got the general advice, zombies included. What am I misunderstanding here? Thanks! Peter. --- It is very difficult to get a man to understand something when his tribal identity depends on his not understanding it - Michael Bérubé on Republican climate change denial. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] not sure if this is a bug of drools or my bad usage...
Hi Wolfgang, First, your rules work... But for the second rule, I replaced the first Reachable() in the when clause to Link(), and the result is still correct. Only if I remove no-loop true, the issue I had appeared. So, I understand how no-loop true in this case helps to make the result correct. But, do you see any scenarios where no-loop can cause incorrect results? For example, not enough number of recursions? Thanks. -Simon 2011/3/8 Wolfgang Laun wolfgang.l...@gmail.com: I think there is some fundamental error in deriving truths from givens and other derived facts that are then interpreted as given truths, and, moreover, with subtly varying semantics. In terms of graph theory: reachability is based on (directed) edges, but it does not establish additional edges. Deriving Reachability should be done by: rule deriveLink when Link( $a: a, $b: b ) then insertLogical(new Reachable($a,$b)); System.out.println( ins reach + $a + + $b ); end rule deriveReachReach no-loop true when Reachable( $a: a, $b: b ) Reachable( a == $b, $c: b != $a ) then insertLogical(new Reachable($a,$c)); end Ideally, I would like to use not Reachable(a == $a, b == $c) instead of the (last resort) no-loop in the second rule, but Drools' truth maintenance is incomplete: it does not let your define the logical dependency on part of the condition (i.e., excluding the CE not in this case). -W On 8 March 2011 05:49, Simon Chen simonche...@gmail.com wrote: What I had is a very simplified version of how calculating transitive closure could go wrong... Let's say we have two rules: rule 1 when link(a,b) then insertLogical(new reachable(a,b)) rule 2 when link(a,b) reachable(b,c) then insertLogical(new reachable(a,c)) Let's say, I have link(a,b), link(b,c), link(b,a), link(c,b). So, we'll have reachable(a,b), reachable(b,c), reachable(a,c), etc. But, after I retract link(a,b) and link(b,a), guess what, reachable(c,a) still exists! This doesn't sound right to me. But in Drools, this is possible, because we have: reachable(c,a) - link(c,b), reachable(b,a) reachable(b,a) - link(b,c), reachable(c,a) The problem here is that we actually inserted reachable(b,a) multiple times: first supported by link(b,a) and rule 1, and secondly by link(b,c) and reachable(c,a) and rule 2. When reachable(b,a) was inserted the second time, link(b,c) and reachable(c,a) become the additional supporting condition - maintained by the truth maintenance system. So, even if link(b,a) is retracted, reachable(b,a) still exists further supporting reachable(c,a). Is it clearer? Thanks. -Simon 2011/3/7 Edson Tirelli ed.tire...@gmail.com: Simon, The behavior seems correct to me as B is justified by either A or C (or both). Of course, from the initial state, A is required for C to first exist, but once it starts to exist, your rules say that B and C justify each other and so both remain in memory. This is design as intended, but do you think that is wrong? Edson 2011/3/7 Simon Chen simonche...@gmail.com Hi all, An interesting finding: I have three simple rules: rule A2B when A() then insertLogical(new B()); end rule B2C when B() then insertLogical(new C()); end rule C2B when C() then insertLogical(new B()); end Basically, once we have an A(), we'll logically insert a B(). Once we have a B(), we'll logically insert a C(). Once we have a C(), we'll logically insert a B(). So, I first insert an A(), print all the objects. Retract A(), and print all the objects. Here's what I got: com.sample.B@42 com.sample.C@43 com.sample.A@548997d1 after retract! com.sample.B@42 com.sample.C@43 So, B() and C(), which should be logically depend on A(), somehow are not retracted. The problem I see is the truth maintenance system allow B() and C() to depend on each other, thus not affected by losing A(). Is this a bug or my bad usage? Thanks. -Simon ___ 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 ___ 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] Is it possible to Iteriate over a list of string values ?
The Expert documentation states The expression used to define the object source is any expression that follows regular MVEL syntax. Therefore from should be able to use the MVEL syntax for arrays [one, two, three] however I've not tried and never seen it used. Normally people use from to iterate over a dynamic list created elsewhere (another Fact pattern, a global etc). Since you say you need to handle variable collections I'd have thought the latter use-case more suitable for yor needs. something like:- when $pch : ParsedCellHolder( ) $val : String( ) from $pch.getStrings( ) then insert( new Fact( $val ) ); end Of course one begs to ask why you don't simply insert the individual values into WM as the spreadsheet is parsed? You'll be doing something like that to either construct the static MVEL in your example or a list. With kind regards, Mike On 9 March 2011 06:19, groovenarula gnaru...@la-z-boy.com wrote: Hello all, In one of my use cases, I need to insert a variable collections of facts into working memory in order to be able to test for those values later : So I was wondering if there's a way to do something like this when $vals : String() from [ A 12345, B 45678, C 8695 ] then insert ( new Fact ( $vals ) ); With the intention that the rule will fire 3 times and insert the 3 new facts with the values A 12345 and B 45678 and C 8695. Is this possible using rules or do I have to resort to using functions. The problem I'm trying to overcome is to see if there's a way to get the A 12345, B 45678, C 8695 from a single cell of a spreadsheet. Thanks in advance, G -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Is-it-possible-to-Iteriate-over-a-list-of-string-values-tp2654135p2654135.html Sent from the Drools - User 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