Re: [rules-users] CPU Spike creating a StatefulKnowledgeSession using OSGi
Interesting. Normally it should be fast. Try to change your patter and load binary compiled serialized package from disk. You can find it in documentation. Also consider using stateless session. Do you really need stateful session? Pavel 2010/8/9 David Conde dco...@calomtech.com: Is it possible that this might be invoking the compiler when a session is created? I have all of the init code in the service start call and stored as members of the service for reuse but I must create a new knowledge session for each run. Any ideas? Thanks, Dave -- Forwarded message -- From: David Conde dco...@calomtech.com Date: 9 August 2010 11:17 Subject: Re: [rules-users] CPU Spike creating a StatefulKnowledgeSession using OSGi To: Rules Users List rules-users@lists.jboss.org The line that it spikes on is StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();. Cheers, Dave On 9 August 2010 11:09, Pavel Tavoda pavel.tav...@gmail.com wrote: Is it session creation or rule compilation? Pavel 2010/8/9 David Conde dco...@calomtech.com: Good Morning, I now have drools running on the Spring DM-Server but I am seeing a CPU spike when creating a StatefulKnowledgeSession. I've tested this outside of an OSGi environment and I don't see the spike. Does anyone know any settings that I can change that might make this go away? Thanks, Dave -- David Conde CTO Calom Technologies ___ 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] drools in a SOA environment
Maybe this doesn't fit your needs but we are using very successfully DroolsAdvice which intercept each service call with AspectJ. It's good for auditing, generating mails for exceptional situations but also for calculation fees on invoices. Here is source code for inspiration: http://fisheye3.atlassian.com/browse/fornax/trunk/cartridges/sculptor/fornax-cartridges-sculptor-framework/src/main/java/org/fornax/cartridges/sculptor/framework/drools/DroolsAdvice.java?r=6407 Regards Pavel 2010/8/10 Dieter D'haeyere dieter.dhaey...@gmail.com: I have some questions regarding the overall view of what is happening where when using Drools in a service oriented environment. This is the idea: Some applications are making use of rules for some calculations. The idea is to be able to call the rule engine as a service. Meaning: passing all facts to the rule base and based on that, rules will be fired and the facts will be updated. Rules will be called a lot so scalability is important. Next to that: the conclusion part should be able to call other services, eg. to do some calculations. An ESB is available so communication could go over that bus. Now: this is how I see it: Drools Guvnor is the place where the rules are stored and managed. (war) Drools Server is where the actual calculations take place. (war but... when more load must be handled, multiple instance could be deployed). The application does a SOAP call to Drools Server (passes facts and commandos) and all is ok... Well .. now the problem starts... I don't get it :) I mean: how does Drools Server talk to the rule base ? I haven't found a clear article (but probably it does exist, just didn't find it yet) where this cooperation is demonstrated. Also: I read about Camel / Spring / Rest which would be the new way to call a service... So SOAP is no longer supported (or will be deprecated as of Drools v5.x ?) An overview and / or some best practices on how to design the architecture would be welcome. Btw, as I understand it now, Drools - grid will be the way to go. But that will probably will be for version 5.2. And then again, I am confused about the split between the rule 'engine' (I have been told that there is not such a thing as a big calculating engine) and the rule repository. I kind of would expect that those two could be coupled tightly together (ok, there is probably a good reason why choices are made as they are, I am way too newbie to interfere in any such discussion). Sincerely, Dieter D'haeyere. ___ 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] CPU Spike creating a StatefulKnowledgeSession using OSGi
Can't you avoid using ChainedProperties, what is it? Can you send piece of code where you create session? Pavel 2010/8/10 David Conde dco...@calomtech.com: Hi Pavel, I've changed it over to use a stateless session and I'm seeing the same behavior. I've done some debugging and it seems to be very slow loading up the SessionConfiguration due to all of the loading that happens in ChainedProperties. Thanks, Dave On 10 August 2010 13:53, Pavel Tavoda pavel.tav...@gmail.com wrote: Interesting. Normally it should be fast. Try to change your patter and load binary compiled serialized package from disk. You can find it in documentation. Also consider using stateless session. Do you really need stateful session? Pavel 2010/8/9 David Conde dco...@calomtech.com: Is it possible that this might be invoking the compiler when a session is created? I have all of the init code in the service start call and stored as members of the service for reuse but I must create a new knowledge session for each run. Any ideas? Thanks, Dave -- Forwarded message -- From: David Conde dco...@calomtech.com Date: 9 August 2010 11:17 Subject: Re: [rules-users] CPU Spike creating a StatefulKnowledgeSession using OSGi To: Rules Users List rules-users@lists.jboss.org The line that it spikes on is StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();. Cheers, Dave On 9 August 2010 11:09, Pavel Tavoda pavel.tav...@gmail.com wrote: Is it session creation or rule compilation? Pavel 2010/8/9 David Conde dco...@calomtech.com: Good Morning, I now have drools running on the Spring DM-Server but I am seeing a CPU spike when creating a StatefulKnowledgeSession. I've tested this outside of an OSGi environment and I don't see the spike. Does anyone know any settings that I can change that might make this go away? Thanks, Dave -- David Conde CTO Calom Technologies ___ 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 ___ 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] Drool Guvnor-Accessing Rules which are expired to do back dated calculations
Hello, forget date-expires. Just make your WHEN condition to match date you specify somewhere in your object as date for which to calculate. Then you will have two rules and each will match different date. Pavel 2010/8/2 Minal Sarmokadam minal.sarmoka...@lntinfotech.com: Hi, I am evaluating Drool Gunvor for to implement Rules for some finance related functionality. I need help from users to implement following scenario is Drools-Guvnor I have created simple Rule to Calculate House Rent Allowance i.e. HRA as HRA = 0.12 * Basic salary .(Basic will come as Input Parameter). This rule is valid from e.g. 01-Jan-2005 to 31-July-2010 as HRA rule is changed from 1st Aug 2010 I will have to create new Rule for HRA Rule with new formula as HRA = 0.15 * Basic salary .(Basic will come as Input Parameter). This rule is valid from 01-Aug-2010 to 01-Aug-2999 From 1st Aug HRA should be calculated using New Rule. But at the same time if any Arrears to be calculated(back dated calculation) depending on the date old HRA rule should be applicable.I would need this to calculate Arrears i.e. doing backdated calculations Can I achieve this in Gunor Drool. I could achieve first half by specifying date-expires . But I am not able to achieve second half i.e. referring old rule depending on the date. I would appreciate help to solve this problem . Thanks in advance. Regards Minal S This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system. __ ___ 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] RuleAgents and containers
In default setup of many servers (which I know) and java has no prohibited reading of files outside ear. You can read changeset and rule files from specific directory e.g. (/etc/rules/...). Or you can use user.home property. We are using it without problems. However you can use other mechanisms which are more appropriate for your setup. For example for clustered environment and better management I will store rules to database or you can use Guvnor. Regards Pavel On Fri, Jul 23, 2010 at 6:56 PM, H.C. canterbu...@gmail.com wrote: Pavel, Thanks for the reply. However, if my change-set file and drl files are not packed in the war/ear but located on the server's file system outside of the app server then I do believe the JEE spec forces me to map an external resource via JNDI? We want this because we need to frequently update the rules without having to repackaging and deploy the application. For this scenario, will the rule agent work correctly? Or... Are you saying that my change-set file should be packaged with my application but point to the drl files located outside of the app server? If so, without using JNDI, wouldn't that break the container provided isolation from the file system? I am thinking this has to work somehow since Drools provides a way to manage and deploy rules via Guvnor which obviously wouldn't always be located on the same server as the execution environment and drools is deployed in plenty of enterprise apps. I just can't quite wrap my head around the correct architecture/setup. Is there maybe a doc about this anywhere? Thanks -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/RuleAgents-and-containers-tp988664p990268.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] how to debug rules in JBoss AS?
You described it well. Did you tried it? It should work. Doesn't matter where are you connected (local JVM or remote JVM). Debugging should work same way. Pavel 2010/7/16 Marina ppi...@yahoo.com: Hello, I know one can debug rules (put breakpoints in .drl and ruleflow files) when running/debugging an application as a Drools Application. However, I would like to debug rules when my application is running in JBoss AS - just like we do a normal debugging of a Remote application running in a different JVM ,by enabling the JDWP on the server (-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n) and then connecting to the specified port. Basically, I would like to be able to debug both my Java classes and rules together. Is it possible? thanks, Marina ___ 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] Get authorized users rules only into application
But you don't need autorization details. packagename=username Pavel On Wed, Jul 14, 2010 at 6:44 AM, G3 charm...@gmail.com wrote: Hi Thanks for your reply. I guess I have to use separate guvnor with a single package for each user only. The webdav shows only the packages and snapshots not the authorization details. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Get-authorized-users-rules-only-into-application-tp959652p965533.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] Rules integration with Java -need help
Just look to Properties documentation. You can set property from java too. Something like: Properties properties = new Properties(); properties.load(new FileInputStream(module2PropertiesFilePath)); properties.setProperty(url, http://MyURL...;) RuleAgent agent = RuleAgent.newRuleAgent(properties); Pavel On Wed, Jul 14, 2010 at 11:58 AM, Dinesh kumar din...@gmail.com wrote: Hi, Need help in integrating guvnor with my java application. I have the set rules to executed for a particular module as individual packages within guvnor. To fire these rules, I have separate properties file specifying the URL of each package and mention it within the application as below. For module1: Properties properties = new Properties(); properties.load(new FileInputStream(module1PropertiesFilePath)); RuleAgent agent = RuleAgent.newRuleAgent(properties); RuleBase ruleBase = agent.getRuleBase(); WorkingMemory workingMemory = ruleBase.newStatefulSession(); workingMemory.insert(module1Object); workingMemory.fireAllRules(); For module2: Properties properties = new Properties(); properties.load(new FileInputStream(module2PropertiesFilePath)); RuleAgent agent = RuleAgent.newRuleAgent(properties); RuleBase ruleBase = agent.getRuleBase(); WorkingMemory workingMemory = ruleBase.newStatefulSession(); workingMemory.insert(module2Object); workingMemory.fireAllRules(); My properties file looks like this. There will be one properties file for each module. ## ## RuleAgent configuration file example ## #setting this means the rulebase will be created fresh whenever there are #changes newInstance=true #this points to a binary compiled rule package, you can have spaces #seperating multiple files #file=/foo/bar/boo.pkg /foo/bar/boo2.pkg #this specifies that packages may appear in a directory #it will pick up whatever files are dumped in there (.pkg files like above) #dir=/my/dir #this specifies a list of urls for packages - these urls #are those that are exposed by the BRMS url= http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Module1/LATEST #the following can be used with the urls to keep a local cache #so if the runtime server is restarted, the BRMS does not need #to be available #localCacheDir= #this specifies the frequency at which the sources will be checked for #changes (in seconds). If you don't set this, it will mean that you have #to manually poll poll=30 #this specifies the name of this config, necessary in case logging is used. name=MyConfig Instead of specifying the url in the properties file, can i directly have the url in my java.. How to directly specify the url in java instead of using properties file? Any suggestions will be of great help.. Regards, Dinesh -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rules-integration-with-Java-need-help-tp966070p966070.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] Get authorized users rules only into application
What about making separate instances of guvnor for each user? How many users you have? Pavel On Mon, Jul 12, 2010 at 8:57 AM, G3 charm...@gmail.com wrote: Hi all I am able to get the entire LATEST package from the package URL from guvnor into my application. But this means any user can run all rules. I want to retrieve the rules created by the user in guvnor when the user logs in into my application or else the user can only run the rules through my application that he has permission to access in guvnor . Can anyone suggest me a good material to look up or help me on the same. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Get-authorized-users-rules-only-into-application-tp959652p959652.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] Drools Flow
But for this you don't need drools flow. Normal rule-set is enough. Pavel 2010/7/9 santosh mukherjee sam.sensat...@gmail.com: Sorry, but in the documentation, it was written that an internal event can be raised over the actions of an Action Node. Anyways, Then when and where to raise the event. Actually I want my process to be in such a way, that whenever a certain event comes , it executes a set of actions. Thanks. 2010/7/9 Mauricio Salatino sala...@gmail.com what are you trying to achieve exactly? An event will not work over an action node. Greetings. 2010/7/8 santosh mukherjee sam.sensat...@gmail.com Hi, I am a newbie to Drools flow. I am trying to generate a sample string event in the action node using the snippet -- context.getProcessInstance().signalEvent(java.lang.String, hiii); But they event is not getting generated. Any suggestions are welcome. Thank You. Santosh Mukherjee ___ 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.jbug.com.ar - Salatino Salaboy Mauricio - ___ 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] Creating and deploying rules to Drools and JRules
Did you looked at drools DSL, templates and spreadsheet support? http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e5495 http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e5765 http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e6212 That is maybe way for your business people. We are using combination of it for building rules. Technical people are using directly Rule language. Business people use DSL and excel sheets for specifying rules. It's easy to understand for business people if you give them correct limited language or simple excel sheet where they can insert their rules. Pavel 2010/6/29 Edson Tirelli tire...@post.com: Varnit, There are initiatives out there on standardizing rules languages (RIF, RuleML, etc) but AFAIK there is no real support for them yet, neither from Drools, nor from JRules side. Mark did worked with someone from iLog (at that time, IBM now) and implemented a proof of context once for the RuleML conference proving it is possible to do it with limited functionality, as RIF is still the minimum common denominator among engines/languages, but if you go that route, it would still require quite a work I imagine. Your best bet IMO is to make your application generate a common canonical model that can then be used to generate both DRL and IRL rules and deploy them on their respective engines. Drools has such a model (represented by our *Descr classes) if you want a starting point. If you want to take the next step and work with us in an IRL parser for Drools, you would be able to roundtrip DRL - IRL automatically, but that would require a bit more effort. Edson 2010/6/29 Varnit Khanna varn...@gmail.com Hi, What will be the best way to achieve the following: We are trying to create a simple web based interface which will allow our marketing team to create rules and then deploy them to either jrules or drools (depending on the client). Is there some standard rules language or library available to achieve this? Thanks, VK ___ 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] Possible bug
Hello, we are using official 5.0 release and sometimes (very rarely) we get following error: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793) at java.util.HashMap$ValueIterator.next(HashMap.java:822) at org.drools.reteoo.ClassObjectTypeConf.getMatchingObjectTypes(ClassObjectTypeConf.java:171) at org.drools.reteoo.ClassObjectTypeConf.getObjectTypeNodes(ClassObjectTypeConf.java:163) at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:143) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788) at org.drools.process.command.InsertObjectCommand.execute(InsertObjectCommand.java:22) at org.drools.process.command.InsertObjectCommand.execute(InsertObjectCommand.java:7) at org.drools.runtime.impl.BatchExecutionImpl.execute(BatchExecutionImpl.java:23) at org.drools.runtime.impl.BatchExecutionImpl.execute(BatchExecutionImpl.java:9) at org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:225) at org.fornax.cartridges.sculptor.framework.drools.DroolsAdvice.applyCompanyPolicy(DroolsAdvice.java:150) We are using AspectJ advice for starting rule evaluation for every service call. Hope we are doing everything right in code. Full source code of advice can be found at: http://fisheye3.atlassian.com/browse/fornax/trunk/cartridges/sculptor/fornax-cartridges-sculptor-framework/src/main/java/org/fornax/cartridges/sculptor/framework/drools/DroolsAdvice.java?r=6407 Regards Pavel ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Possible bug
Maybe yes, advice is generic but I looked at source code and from what I see iteration is going through some internal cache which is maybe concurrently modified not through items of my Hash. for ( ObjectTypeNode node : ruleBase.getRete().getObjectTypeNodes( this.entryPoint ).values() ) { Anyway modifying fact will be wrong idea ;-). Pavel On Mon, Jun 28, 2010 at 3:36 PM, PAYET, Manuel manuel.pa...@capgemini.com wrote: My last message presumes that you inserted a Map fact, was I wrong? -Message d'origine- De : rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] De la part de Pavel Tavoda Envoyé : lundi 28 juin 2010 15:29 À : Rules Users List Objet : [rules-users] Possible bug Hello, we are using official 5.0 release and sometimes (very rarely) we get following error: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793) at java.util.HashMap$ValueIterator.next(HashMap.java:822) at org.drools.reteoo.ClassObjectTypeConf.getMatchingObjectTypes(ClassObjectTypeConf.java:171) at org.drools.reteoo.ClassObjectTypeConf.getObjectTypeNodes(ClassObjectTypeConf.java:163) at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:143) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788) at org.drools.process.command.InsertObjectCommand.execute(InsertObjectCommand.java:22) at org.drools.process.command.InsertObjectCommand.execute(InsertObjectCommand.java:7) at org.drools.runtime.impl.BatchExecutionImpl.execute(BatchExecutionImpl.java:23) at org.drools.runtime.impl.BatchExecutionImpl.execute(BatchExecutionImpl.java:9) at org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:225) at org.fornax.cartridges.sculptor.framework.drools.DroolsAdvice.applyCompanyPolicy(DroolsAdvice.java:150) We are using AspectJ advice for starting rule evaluation for every service call. Hope we are doing everything right in code. Full source code of advice can be found at: http://fisheye3.atlassian.com/browse/fornax/trunk/cartridges/sculptor/fornax-cartridges-sculptor-framework/src/main/java/org/fornax/cartridges/sculptor/framework/drools/DroolsAdvice.java?r=6407 Regards Pavel ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. ___ 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] Possible bug
We are using community edition. I will ask customer to update to RedHat version. Thank you Pavel 2010/6/28 Edson Tirelli tire...@post.com: Pavel, This is a bug. It was fixed last week: https://jira.jboss.org/browse/JBRULES-2556 When you say you are using the official 5.0 version, do you mean the Red Hat supported version or the community version? If you are a Red Hat subscriber, you can ask them to provide you with a patch. Edson 2010/6/28 Pavel Tavoda pavel.tav...@gmail.com Maybe yes, advice is generic but I looked at source code and from what I see iteration is going through some internal cache which is maybe concurrently modified not through items of my Hash. for ( ObjectTypeNode node : ruleBase.getRete().getObjectTypeNodes( this.entryPoint ).values() ) { Anyway modifying fact will be wrong idea ;-). Pavel On Mon, Jun 28, 2010 at 3:36 PM, PAYET, Manuel manuel.pa...@capgemini.com wrote: My last message presumes that you inserted a Map fact, was I wrong? -Message d'origine- De : rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] De la part de Pavel Tavoda Envoyé : lundi 28 juin 2010 15:29 À : Rules Users List Objet : [rules-users] Possible bug Hello, we are using official 5.0 release and sometimes (very rarely) we get following error: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793) at java.util.HashMap$ValueIterator.next(HashMap.java:822) at org.drools.reteoo.ClassObjectTypeConf.getMatchingObjectTypes(ClassObjectTypeConf.java:171) at org.drools.reteoo.ClassObjectTypeConf.getObjectTypeNodes(ClassObjectTypeConf.java:163) at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:143) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788) at org.drools.process.command.InsertObjectCommand.execute(InsertObjectCommand.java:22) at org.drools.process.command.InsertObjectCommand.execute(InsertObjectCommand.java:7) at org.drools.runtime.impl.BatchExecutionImpl.execute(BatchExecutionImpl.java:23) at org.drools.runtime.impl.BatchExecutionImpl.execute(BatchExecutionImpl.java:9) at org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:225) at org.fornax.cartridges.sculptor.framework.drools.DroolsAdvice.applyCompanyPolicy(DroolsAdvice.java:150) We are using AspectJ advice for starting rule evaluation for every service call. Hope we are doing everything right in code. Full source code of advice can be found at: http://fisheye3.atlassian.com/browse/fornax/trunk/cartridges/sculptor/fornax-cartridges-sculptor-framework/src/main/java/org/fornax/cartridges/sculptor/framework/drools/DroolsAdvice.java?r=6407 Regards Pavel ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. ___ 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 -- 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
Re: [rules-users] Using in or not in operator in a DSL
DSL processor work with TEXT. Try something like this: [condition][]- person is {years} years old=Age (value in ({years})) Pavel On Wed, May 12, 2010 at 2:16 PM, Joerg Herbst herbsthanno...@googlemail.com wrote: Hi folks, I'm trying to create a DSL where the user should be able to add a bunch of values, as when using the normal rule syntax. The DSL should look something this: when person is not 18,21, 100 years old then normal birthday end My problem is I don't know the number of arguments. When I write a normal rule I can say somethink like: Age (value in (18,21,100)) But how can I achieve this in a DSL syntax? Thanks Joerg ___ 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 - Query Problem
Another simple way will be to declare global variable like: global List EBandRating; and in then clause you can do: EBandRating.add(r); You don't have to make queries, no-loops, lock-on-active or other tricky stuff. Pavel 2010/3/29 Esteban Aliverti esteban.alive...@gmail.com: Hi, What Wolfgang is trying to say about inform the Drools engine about the update is that you need to use a modify statement in your RHS. Your rule should look like this: rule for E band lock-on-active true when r : Rating( rate == 1) then modify(r){ setBand(EBand); } System.out.println( in E band ); end This is the way to inform Drools that your Fact is modified. But be careful, because when you modify a Fact, all the rules are evaluated again because the modification could activate another Rule. This will end in an infinite loop (just like Wolfgang mentioned), the for E band rule will be executed for ever. That's why you need to add the no-loop attribute (if the only rule that modifies a Rating is for E band) or lock-on-active (if more than one rule could modify a Rating). On Mon, Mar 29, 2010 at 7:20 AM, Wolfgang Laun wolfgang.l...@gmail.com wrote: You have to inform the Drools engine about the update done with r.setBand(...), or else the query condition is still seeing the fact state at insert time. You may have to add the no-loop option to your rules. (Also, comments and actions disagree, e.g. D Band vs. EBand) -W On 3/29/10, Nilima R nilim...@tcs.com wrote: Dear All, I have created simple rule file and created model in that rule file only package com.sample import java.lang.String; declare Rating rate : int band : String name : String end query employee with band E ratg : Rating(band == EBand) end rule for E band when r : Rating( rate == 1) then r.setBand(EBand); System.out.println( in E band ); end rule for D band when r : Rating( rate == 2) then r.setBand(EBand); System.out.println( in E band ); end rule for C band when r : Rating( rate == 3) then r.setBand(EBand); System.out.println( in E band ); end rule for B band when r : Rating( rate == 4) then r.setBand(EBand); System.out.println( in E band ); end At the end I want to know how many employees have got E band and so have written query for it in the rule file .and obtained the query results as below FactType bandType = kbase.getFactType( com.source, Rating ); QueryResults results = ksession.getQueryResults( employee with band E); System.out.println( we have + results.size() + employee with band E ); System.out.println( employee with band E: ); for (Iterator i = results.iterator(); i.hasNext();) { QueryResultsRow row = (QueryResultsRow)i.next(); Object ratg = row.get(rating); String name = (String) bandType.get( ratg, name ); System.out.println(name); } But am getting the result of query as 0 records. i am inserting objects one by one ( this for testing just purpose ) to learn how query works. Can someone plz point out what is wrong.Its Urgent Thanks in advance. Nilu =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Esteban Aliverti ___ 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] Inheritance-Like Design Question
Sorry don't watch thread in detail but something like this should be achieved by defining salience on rule. Usually you define same condition withing same activation group with e.g. salience -100 which will fire as default when nothing match. But maybe I'm totally out of scope Pavel 2010/3/9 Moe Alkhafaji moe.alkhaf...@medcpu.com: So, in continuation of the main subject of the email. Unfortunately, I cannot use activation group because that will only allow me to execute one rule out of many children. I want all eligible children to execute, without the parent. And, if none of the children execute, then execute the parent (obviously providing that all conditions are true). Sort of like how overriding works in OOP. Unless the child has an overriding method, the one from the super class will execute. Otherwise, the one from the child will execute. I said sort of like OOP, because here I want when ANY child execute, the parent is not eligible to evaluate anymore, and if NONE of the children rules execute (evaluate to false) then evaluate the parent rule. So, here is what I am exploring but I don't know how to do in Drools, and whether there is a support for it: I was hoping that I can use salience to make all child rules evaluation first. If a child rule executes, I want to listen to that event, and query this rule to see whether it has a parent rule or not. If it does, then deactivate that parent rule right in the event handler. I couldn't see anything in the API on finding the parent of a given rule. Would this be a meta data item or something? Is there a clever way to find out what the parent rule is without introducing a custom method to have the child rule registers itself? My second question is, I am feeding only one fact to the entire rule engine instance. I am using the following syntax to define the input object: mpr : MPRFacade() I am declaring that in all my rules. Now, that I am using the extends syntax, I cannot declare the same variable in both parent and child rules. How can I use the mpr declared in the parent right from within the child rule? I tried this, super, etc. with no success. If it is inaccessible, then why the heck it is telling me it is a duplicate when I try to declare it? :) Thanks guys and gals! 2010/3/8 Edson Tirelli ed.tire...@gmail.com Thanks for letting us know. Good luck! Edson 2010/3/8 Moe Alkhafaji moe.alkhaf...@medcpu.com I just want to report that using Eclipse 3.5.2, inheritance worked beautifully! Thanks. Now, I am going to get to the actual problem at hand and try to find a solution. Thanks Edson for all your help in this. 2010/3/8 Edson Tirelli ed.tire...@gmail.com Yes, probably so. Eclipse 3.4 and 3.5 should be fine. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Moe Alkhafaji Chief Technology Officer, MedCPU Phone: (630) 290-1113 Email: c...@medcpu.com This message contains information which may be confidential. Unless you are the addressee, you may not use, copy or disclose to anyone the message or any information contained in this message. If you have received this email in error, please notify c...@medcpu.com and please delete the message immediately. In order for the contents of this message to be binding on behalf of MedCPU it must be confirmed in writing by an authorized signatory of MedCPU. Our company accepts no liability for the content of this email unless it is so confirmed. The views or opinions presented herein do not necessarily represent those of the company. ___ 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] Inheritance-Like Design Question
Aha, misunderstanding. Yes you can't use activation group if you want execute more children rules. However you can use fact (Status) to avoid evaluating parent rule. My suggestion: Rule DEFAULT salience -100 if A and ! Status(done) then DEFAULT end Rule A if A and B then SOMETHINGB; update(Status(done)) end Rule B if A or B then SOMETHINGB; update(Status(done)) end Rule C if A or C then SOMETHINGC; update(Status(done)) end At beginning insert Status with e.g. ready. It's possible to use instead of update also insert but because you can fire more children rules it will be waste of memory. Hope this help Pavel ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Inheritance-Like Design Question
For this you have DSL. It's very good for end users. 80% of work will be done in nice predefined language which you build for them. Advanced features should be temporarily patched by using at beginning of line with normal Drools syntax. Look for DSL in Drools manual. Or you can use excel or templates. What control logic rules are doing? Can't you deduce from some other object that action was done? Than you should avoid Status object. Pavel 2010/3/9 Moe Alkhafaji moe.alkhaf...@medcpu.com: Thanks Pavel. I was hoping for more of a transparent functionality supported by Drools than have my users add those control method calls. I am trying to make their rules as control logic blind as possible. But, I guess they would have to do that. Also, any idea on re-using an object from the parent rule? What is the syntax for using an object declared in the parent rule? Thanks. On Tue, Mar 9, 2010 at 11:25 AM, Pavel Tavoda pavel.tav...@gmail.com wrote: Aha, misunderstanding. Yes you can't use activation group if you want execute more children rules. However you can use fact (Status) to avoid evaluating parent rule. My suggestion: Rule DEFAULT salience -100 if A and ! Status(done) then DEFAULT end Rule A if A and B then SOMETHINGB; update(Status(done)) end Rule B if A or B then SOMETHINGB; update(Status(done)) end Rule C if A or C then SOMETHINGC; update(Status(done)) end At beginning insert Status with e.g. ready. It's possible to use instead of update also insert but because you can fire more children rules it will be waste of memory. Hope this help Pavel ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Moe Alkhafaji Chief Technology Officer, MedCPU Phone: (630) 290-1113 Email: c...@medcpu.com This message contains information which may be confidential. Unless you are the addressee, you may not use, copy or disclose to anyone the message or any information contained in this message. If you have received this email in error, please notify c...@medcpu.com and please delete the message immediately. In order for the contents of this message to be binding on behalf of MedCPU it must be confirmed in writing by an authorized signatory of MedCPU. Our company accepts no liability for the content of this email unless it is so confirmed. The views or opinions presented herein do not necessarily represent those of the company. ___ 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] Problem with date
How was suggested before (in other thread) you can: 1) use getTime() method of Date class which return long and compare 2) use some good library for example Joda time with eval() Pavel 2010/3/8 Bertrand Grottier b_grott...@hotmail.com: Hello, Ok, I understand the problem. dDeb is indeed a Date type. What is the proper/simplest way to achieve such a comparison ? Thank you in advance for your help. Regards, Benoît Date: Thu, 4 Mar 2010 10:01:23 + From: ejdigg...@gmail.com To: rules-users@lists.jboss.org Subject: Re: [rules-users] Problem with date Hi, What is the type of the dDeb field? It looks like you're trying to check if a date is less than a string. Enda 2010/3/3 Bertrand Grottier b_grott...@hotmail.com Dear all, I am a newbie with Drools (Drools 5). I just want to make a date comparison but failed until now. Here is my drl file : package com.sample import com.sample.DroolsTest.Produit; rule Prix premier semestre when p1 : Produit( dDeb 01-Jan-2010 ) then p1.setPrix( 10 ); update( p1 ); end I get a build error in Eclipse : Unable to create restriction. This must be an obvious problem but I am struggling for a while now. Any help would be appreciated. Benoit Commander un cadeau en ligne discrètement? Voir la solution offerte par Internet Explorer8 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Enda J Diggins Envie de naviguer sur Internet sans laisser de trace? La solution avec Internet Explorer 8 ___ 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] Inferencing
It's like synchronous vs. asynchronous communication. In reality it's always asynchronous but from top view it appear synchronous. Similar to stateless vs. statefull. Statefull is just series of stateless session where you transfer state from one session to another. Look for Drools statefull persistency. In reality it is series of stateless sessions where you store status from one session result and use it as start for another session plus some new changes. This is my point of view of difference between stateless/statefull session specially how Drools make it. Regards Pavel On Mon, Mar 8, 2010 at 4:23 PM, Tim de Jager tim.deja...@student.hu.nl wrote: Hi everybody, I'm currently doing my bachelor thesis on Rule engines. This includes comapring different Rule engine products. I have set up a small Java program (Conway's game of life) and I'm writing the 'engine' in different Rule engines, while keeping the same GUI,CellGrid etc. I have already made a Drools based engine. I have been studying the Rule engine subject for somewhat more then a month now. And I'm currently seeing two different developments namely the use of an inference engine and the generation of embedded code instead (Take, Visual Rules etc.) I can see some of the pro's and cons with both paradigms. But I'm wondering what opinion some of you guys have on the subject. I can see that without inferencing it is very hard (or even impossible) to keep a statefull session inside the rule engine, haven't seen a non-inferencing rule engine which does offer this possibility. And also lose features like TMS. But what would be a concrete example where a statefull session is absolutely necessary? Instead of letting the engine reason over all the facts in stateless way. And managing conflicts with a ruleflow (see Visual Rules for a nice example). I'm looking forward to hearing your thoughts. Thanks, Tim P.S I already read two of Mark Proctors blogs on inferencing, but while enlightening, they didn't supply me with a definitive awnser -- View this message in context: http://n3.nabble.com/Inferencing-tp435411p435411.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] Inferencing
Yes you are right but that should be a hidden detail like asynchronous connect is internally synchronous because you are waiting for confirmation packet (but not response) ;-). No way to implement execution without changing global state - am I right? BTW I implemented for one small subproject (IRC bot) mechanism where I listen to all new memory inserts and repeat them at beginning of next stateless session with new KnowledgeBase. Very simple and straightforward just 20 lines of code because I don't have to serialize it just keep in memory for next run. Pavel 2010/3/8 Edson Tirelli ed.tire...@gmail.com: Interesting analogy, but careful here: Statefull is just series of stateless session where you transfer state from one session to another. Not sure what lead you to think that way, but it is actually the opposite, and trying to explain that will make things REALLY confusing for some. So, I would recommend anyone not interested in knowing internal details to **stop reading here**! Ok, if you are still reading, then I will try to explain in the simplest way I can: there is no such thing as stateless session in Drools internals. Deep in drools internals, there is only stateful working memory, that is exposed to the user in 2 different ways: a properly stateful session, that allows users to manage the state, and a helper object that we call staless session. This helper staless session object, among other things, simply holds a reference to the kbase and when the execute(...) method is called, internally it creates a stateful session, inserts the facts, fire the rules and disposes the session automatically. There are a bunch of other helper mechanisms there, but the essence is just that: simplify the use of stateful sessions for stateless scenarios. Edson 2010/3/8 Pavel Tavoda pavel.tav...@gmail.com It's like synchronous vs. asynchronous communication. In reality it's always asynchronous but from top view it appear synchronous. Similar to stateless vs. statefull. Statefull is just series of stateless session where you transfer state from one session to another. Look for Drools statefull persistency. In reality it is series of stateless sessions where you store status from one session result and use it as start for another session plus some new changes. This is my point of view of difference between stateless/statefull session specially how Drools make it. Regards Pavel On Mon, Mar 8, 2010 at 4:23 PM, Tim de Jager tim.deja...@student.hu.nl wrote: Hi everybody, I'm currently doing my bachelor thesis on Rule engines. This includes comapring different Rule engine products. I have set up a small Java program (Conway's game of life) and I'm writing the 'engine' in different Rule engines, while keeping the same GUI,CellGrid etc. I have already made a Drools based engine. I have been studying the Rule engine subject for somewhat more then a month now. And I'm currently seeing two different developments namely the use of an inference engine and the generation of embedded code instead (Take, Visual Rules etc.) I can see some of the pro's and cons with both paradigms. But I'm wondering what opinion some of you guys have on the subject. I can see that without inferencing it is very hard (or even impossible) to keep a statefull session inside the rule engine, haven't seen a non-inferencing rule engine which does offer this possibility. And also lose features like TMS. But what would be a concrete example where a statefull session is absolutely necessary? Instead of letting the engine reason over all the facts in stateless way. And managing conflicts with a ruleflow (see Visual Rules for a nice example). I'm looking forward to hearing your thoughts. Thanks, Tim P.S I already read two of Mark Proctors blogs on inferencing, but while enlightening, they didn't supply me with a definitive awnser -- View this message in context: http://n3.nabble.com/Inferencing-tp435411p435411.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 -- 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
Re: [rules-users] Drools memory usage issue
At first start with tuning JVM. Xms, Xmx parameters. How much physical memory you have? If above 3.xx GB you need 64 bit JVM. If this is not enough just kick Profiler. Pavel 2010/3/2 Shah, Malay malay.s...@morganstanley.com: Hi, We have an drools 5.0.1 application that uses StatelessSession and high volume of objects (facts) that we need to apply static rules on, and having out of memory issues doing so. We added the following three properties as given in the drools documentation for decreasing the memory usage: drools.shadowproxy=false drools.maintainTms=false drools.sequential=true As per the following blog, there is an algorithm to minimize the engine work, and memory usage. http://blog.athico.com/2007/07/sequential-rete.html Are the properties above sufficient to trigger this algorithm, or do we need to do write extra code for this? Also, does the drools.sequential property make sure that rules are applied sequentially on facts? If so, is there a hook into the drools engine to figure out which particular rule is consuming more memory or having more execution time? Thanks in advance. Malay Shah NOTICE: If received in error, please destroy, and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. We may monitor and store emails to the extent permitted by applicable law. ___ 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] Rule Templates and null values
Enlighten us. Where is this method and how to use it? I'm also interested. Palo 2010/2/26 Bernd Rücker bernd.ruec...@camunda.com: Okay, digging more into the source code I found the method “replaceOptionals” which does exactly what I need. So despite the missing docs, a line IS skipped if the according parameter used in that line is null. Perfect :-) Sorry for the interruption… Von: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] Im Auftrag von Bernd Rücker Gesendet: Freitag, 26. Februar 2010 12:30 An: rules-users@lists.jboss.org Betreff: [rules-users] Rule Templates and null values Hi all. I question myself if I can get the Rule Templates to works like it is in Excel: If one “parameter” is not set (null), the whole line of the template is skipped? Since we want to build a template for a lot of rules, fed from a database. There some conditions can be null, so they should not be included in the rule at all. Has anybody an idea to this? I haven’t found anything, neither in the docs, nor in the testcases… Thanks a lot Bernd ___ 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] Comparing Date with || OR operator
What about: Membership ( $regDate : regDate) Segment ($endDate : endDate, startDate $regDate || startDate endDate ) Logically startDate endDate doesn't make sense but it should work ;-) Pavel 2010/2/24 Shabbir Dhari sdh...@hotmail.com: I tried with some thing different and it worked but I don’t want this as I have many collections in my data structure. //this works Membership ( $regDate : regDate) Segment ( $endDate : endDate ) Segment ( startDate $regDate || startDate $endDate ) //this does NOT work Membership ( $regDate : regDate) Segment ($endDate : endDate, startDate $regDate || startDate $endDate ) From: sdh...@hotmail.com To: rules-users@lists.jboss.org Date: Tue, 23 Feb 2010 23:09:50 + Subject: Re: [rules-users] Comparing Date with || OR operator Segment ( $endDate : endDate, startDate $regDate || startDate $endDate ) even does not work. I am using verstion 5.0.1. All dates are java.util.Date and values in sample fact are: regDate = Fri Aug 01 00:00:00 BST 2008 startDate = Tue Sep 01 00:00:00 BST 2009 endDate = Fri Jul 30 00:00:00 BST 2010 Stack trace: java.lang.NullPointerException at org.drools.reteoo.LeftTuple.get(LeftTuple.java:265) at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300) at org.drools.rule.VariableRestriction$ObjectVariableContextEntry.updateFromTuple(VariableRestriction.java:320) at org.drools.rule.AbstractCompositeConstraint$MultiFieldConstraintContextEntry.updateFromTuple(AbstractCompositeConstraint.java:305) at org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstraints.java:119) at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:109) at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117) at org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:78) at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:142) at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42) at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185) at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788) at org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:192) at au.gov.nsw.osr.zena.rules.AnnualRulesTester.main(AnnualRulesTester.java:57) Date: Tue, 23 Feb 2010 12:54:46 +0100 From: wolfgang.l...@gmail.com To: rules-users@lists.jboss.org Subject: Re: [rules-users] Comparing Date with || OR operator Please try this rewrite of the 2nd CE: Segment ( $endDate : endDate, startDate $regDate || startDate $endDate ) and report the outcome to the list, together with the Dools version you are using. Thank you. 2010/2/23 dhari sdh...@hotmail.com: Hi Thomas Thanks your prompt reply. I am sure all three attributes are NOT null. I have tested them before sending question to mailing list. If you want, I can send complete sample code and you can try it at your end. Regards, Dhari Date: Tue, 23 Feb 2010 02:50:08 -0800 From: [hidden email] To: [hidden email] Subject: Re: Comparing Date with || OR operator If it works fine with an and operator then I’d imagine that startDate $regDate returns false, with an this would abort evaluation immediately but with an or it would mean that startDate endDate is evaluated and so presumably it is this bit that is throwing the NPE. I’d imagine that the most likely reason for this would be that endDate is null. Try changing it too Segment ( startDate $regDate || (endDate != null startDate endDate) ) And see whether you loose the NPE. Thomas From: [hidden email] [mailto:[hidden email]] On Behalf Of dhari Sent: 23 February 2010 06:15 To: [hidden email] Subject: [rules-users] Comparing Date with || OR operator The following code generates NPE in ReteTuple.java rule when Membership ( $regDate : regDate) Segment ( startDate $regDate || startDate endDate ) then System.err.print(“Invalid start date”); end I am new in Drools and don’t know much about DRL scripting. It works fine I use operator instead. View this message in context: Comparing Date with || OR operator Sent from the Drools - User mailing list archive at Nabble.com.
[rules-users] soundslike crash on 5.0.1
Maybe it's already fixed in 5.1 trunk but: :-) soundslike smile crashes Pavel ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Comparing Date with || OR operator
I just read you condition. You are building $endDate to Segment.endDate and than comparing Segment.startDate with $endDate what is same as comparing Segment.startDate with Segment.endDate - transition principle. Pavel 2010/2/24 Shabbir Dhari sdh...@hotmail.com: Hi Pavel I really don’t understand what do you mean. I guess you didn’t read complete thread carefully. Assigning endDate attribute in a variable and not using that variable in condition make no sense to me. Shabbir Date: Wed, 24 Feb 2010 10:54:24 +0100 From: pavel.tav...@gmail.com To: rules-users@lists.jboss.org Subject: Re: [rules-users] Comparing Date with || OR operator What about: Membership ( $regDate : regDate) Segment ($endDate : endDate, startDate $regDate || startDate endDate ) Logically startDate endDate doesn't make sense but it should work ;-) Pavel 2010/2/24 Shabbir Dhari sdh...@hotmail.com: I tried with some thing different and it worked but I don’t want this as I have many collections in my data structure. //this works Membership ( $regDate : regDate) Segment ( $endDate : endDate ) Segment ( startDate $regDate || startDate $endDate ) //this does NOT work Membership ( $regDate : regDate) Segment ($endDate : endDate, startDate $regDate || startDate $endDate ) From: sdh...@hotmail.com To: rules-users@lists.jboss.org Date: Tue, 23 Feb 2010 23:09:50 + Subject: Re: [rules-users] Comparing Date with || OR operator Segment ( $endDate : endDate, startDate $regDate || startDate $endDate ) even does not work. I am using verstion 5.0.1. All dates are java.util.Date and values in sample fact are: regDate = Fri Aug 01 00:00:00 BST 2008 startDate = Tue Sep 01 00:00:00 BST 2009 endDate = Fri Jul 30 00:00:00 BST 2010 Stack trace: java.lang.NullPointerException at org.drools.reteoo.LeftTuple.get(LeftTuple.java:265) at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300) at org.drools.rule.VariableRestriction$ObjectVariableContextEntry.updateFromTuple(VariableRestriction.java:320) at org.drools.rule.AbstractCompositeConstraint$MultiFieldConstraintContextEntry.updateFromTuple(AbstractCompositeConstraint.java:305) at org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstraints.java:119) at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:109) at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117) at org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:78) at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:142) at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42) at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185) at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788) at org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:192) at au.gov.nsw.osr.zena.rules.AnnualRulesTester.main(AnnualRulesTester.java:57) Date: Tue, 23 Feb 2010 12:54:46 +0100 From: wolfgang.l...@gmail.com To: rules-users@lists.jboss.org Subject: Re: [rules-users] Comparing Date with || OR operator Please try this rewrite of the 2nd CE: Segment ( $endDate : endDate, startDate $regDate || startDate $endDate ) and report the outcome to the list, together with the Dools version you are using. Thank you. 2010/2/23 dhari sdh...@hotmail.com: Hi Thomas Thanks your prompt reply. I am sure all three attributes are NOT null. I have tested them before sending question to mailing list. If you want, I can send complete sample code and you can try it at your end. Regards, Dhari Date: Tue, 23 Feb 2010 02:50:08 -0800 From: [hidden email] To: [hidden email] Subject: Re: Comparing Date with || OR operator If it works fine with an and operator then I’d imagine that startDate $regDate returns false, with an this would abort evaluation immediately but with an or it would mean that startDate endDate is evaluated and so presumably it is this bit that is throwing the NPE. I’d imagine that the most likely reason for this would be that endDate is null. Try changing it too Segment ( startDate $regDate || (endDate != null startDate endDate) ) And see whether you loose the NPE.
Re: [rules-users] Disable rules at runtime to make sure they get executed only once
Maybe here is some complex support for this but if you use ruleflows than it's complicated however what about (noob idea): rule first - only once when not RuleXor( name == first) ... than insert (new RuleXor(first)); end On Fri, Feb 19, 2010 at 2:01 PM, Malinda Kaushalye kausha...@yahoo.com wrote: Hi All, I need to write a set of rules that each get executed only ONCE. However, the conditions are met at different stage of execution as events are coming thru a stream. Therefore I need to disable each rule at different stages. I was looking for some mechanism to disable a rule after it gets executed. Something like this. rule myExecuteOnlyOnceRule when //some condition tat evaluate events then this.rule.disable() / disable(drools.getRule()) end Let me know if you know such a function or a workaround for this issue. Cheers, Malinda ___ 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] How many KnowledgeBases?
I will show you our approach. We have rules in rule base like: rule start calculate when RULE TO START CALCULATION than insert(new CalculateFee(firstFee,secondFee.split(,))) end rule END calculate salience -100 when RULE TO START CALCULATION $fee:CalculateFee() than CALCULATE AND DO WHAT YOU WANT, YOU HAVE FEES IN $fee end Than we have excell sheet with columns: $fee: CalculateFee(feeTypes contains $param);OTHERCODITIONS;$fee.addFee($param) firstFee;...;15% firstFee;...;20% $fee: CalculateFee(feeTypes contains $param);OTHERCODITIONS;$fee.addAbsoluteFee($param) secondFee;;5 secondFee;;15 secondFee;;25 secondFee;;35 In rules you specify which price table to apply when and what to do with fees. In excel sheet you can specify price tables. For more detail look to http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e5765 Hope this help Pavel 2010/2/19 Laird Nelson ljnel...@gmail.com: Forgive me for what I suspect is an elementary question. That said, I did not see it explained in newcomer-friendly language in the documentation, if at all. And I'm a newcomer! I'm working on a system for--among other things--pricing things. Drools Expert is a great fit for this. The system also has to do other things that have nothing to do with pricing (let's say shipping, to keep it simple). There are places where Drools Expert is a great fit for this as well. In both cases, let's assume I might insert a given product into the engine, turn the crank, and collect my results. But the kinds of results I'm looking for--and the kinds of calculations I would expect to be performed--are quite different in each case. So, let's assume that--naively speaking here--when I insert the product and {handwave handwave} I know I'm doing pricing work, then I only need pricing-related rules to fire (I don't need the, say, product-color-determining rules to fire, or the can-the-product-be-shipped-to-Abu-Dhabi rules to fire, or the how-many-people-liked-this-product rules to fire, etc.). And when I insert the product and {handwave handwave} I know I'm doing--whatever--shipping work, then I don't need the pricing rules to even be considered. I found this (http://n3.nabble.com/Grouping-rules-td55531.html#a55531) as perhaps one way of creating different sets of rules to be evaluated in different contexts. This smelled very arcane to me for this purpose, but...? perhaps it's the way to go? Another is obviously to create n KnowledgeBases, each with its own set of rules, where n is the number of contexts or activities or types of activities that I'm performing. Then I'd look up the (pre-created) KnowledgeBase appropriate for the particular calculation I need performed. That seems like solving the problem with a crowbar, a length of iron pipe and a blowtorch. Ick. Is there an accepted/preferred way to handle this sort of thing? Agenda-groups seem...well, perhaps they'd work, but it seems awfully arcane for something that I was hoping would be a little more end-user friendly. Quoting the Expert manual: When Should You Use A Rule Engine? [...] Domain experts often possess a wealth of knowledge about business rules and processes. They typically are nontechnical, but can be very logical. Rules can allow them to express the logic in their own terms. Of course, they still have to think critically and be capable of logical thinking. My domain users would almost certainly not think in terms of agenda groups. Perhaps I could hide this in a DSL or something, but it seems to me there must be some facility built into Drools for separating collections of rules into channels, or groups, or partitions, or Is there? Best, Laird ___ 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] Disable rules at runtime to make sure they get executed only once
Of course it doesn't matter which object you use. Use something natural to your project. Mechanism is same. Pavel On Sat, Feb 20, 2010 at 7:58 AM, Malinda Kaushalye kausha...@yahoo.com wrote: Many thank Pavel. But I dont think I followed RuleXor in your reply. But I tried to insert an event with a key value in the RHS. The same value I used in LHS with other business logic to avoid repeated execution. e.g. when not EventR(Id=KEY) //Other logic then //Other executions insert(new EventR(KEY); If I get your answer correct, this is similar to what you suggest. However, that solution seems bit ugly. It makes the other business logic very difficult to read. That's why I wanted to find a proper way to do that, uding drools API. Cheers, Malinda - Original Message From: Pavel Tavoda pavel.tav...@gmail.com To: Rules Users List rules-users@lists.jboss.org Sent: Sat, 20 February, 2010 12:18:33 AM Subject: Re: [rules-users] Disable rules at runtime to make sure they get executed only once Maybe here is some complex support for this but if you use ruleflows than it's complicated however what about (noob idea): rule first - only once when not RuleXor( name == first) ... than insert (new RuleXor(first)); end On Fri, Feb 19, 2010 at 2:01 PM, Malinda Kaushalye kausha...@yahoo.com wrote: Hi All, I need to write a set of rules that each get executed only ONCE. However, the conditions are met at different stage of execution as events are coming thru a stream. Therefore I need to disable each rule at different stages. I was looking for some mechanism to disable a rule after it gets executed. Something like this. rule myExecuteOnlyOnceRule when //some condition tat evaluate events then this.rule.disable() / disable(drools.getRule()) end Let me know if you know such a function or a workaround for this issue. Cheers, Malinda ___ 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
[rules-users] AGE problem
Hello, I would like to calculate AGE of object based on Date inside object, I can use eval but I hope it's so basic functionality that Drools should have it. It's also performance problem if I need to use EVAL in many rules (let's say 100 in XLS). I'm playing with some FUSION features like: $now : Now() $order : SecurityOrder(this before[400d, 0d] $now) should work but I can't specify YEARS as constant. That's a problem for long time because 30*365d isn't same as 30 years if you consider leap years. Is it possible some easy way to calculate AGE of something with correct time handling and compare to years? Something like: SecurityOrder( age(createdDate) 20y, age(createdDate) 25y) or by FUSION: $now : Now() $order : SecurityOrder(this before[25y, 20y] $now) For now I'm using following function in eval() but it's becoming performance problem: function boolean between(Calendar currentDate, Date oldDate, int from, int to) { Calendar fromCal = Calendar.getInstance(); fromCal.setTime(oldDate); fromCal.add(Calendar.YEAR, from); Calendar toCal = Calendar.getInstance(); toCal.setTime(oldDate); toCal.add(Calendar.YEAR, to); return currentDate.after(fromCal) currentDate.before(toCal); } Thank you Pavel ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users