[rules-users] Raising event signal from work item handler
Within a work item, if you need to signal an event how would you do it? From a rules task you have access to the kcontext but generically this isn't available. Thanks, Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Raising event signal from work item handler
We are trying to work out how to simply perform error handling within a workflow - where any implementation of a work item can detect an exception circumstance and then cause the workflow to abort with the relevant information and error handling. We currently do this by the work item handler catching the exception, setting it as an out parameter, having a split node after every step which then forks to an error handler step and then an abort step. This means more of the flow is boiler plate error handling logic than the actual important business logic - making it much harder to maintain and understand. Signals seem like they should be a cleaner way to implement this without branching and duplicate nodes for every business step. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mauricio Salatino Sent: 08 March 2012 16:48 To: Rules Users List Subject: Re: [rules-users] Raising event signal from work item handler Do you mean a ksession.signalEvent()?? Usually the work item is considered an execution outside the process context, so are not supposed to access the process context from there. Can you explains us a little bit about your use case? 2012/3/8 Swindells, Thomas tswinde...@nds.commailto:tswinde...@nds.com Within a work item, if you need to signal an event how would you do it? From a rules task you have access to the kcontext but generically this isn't available. Thanks, Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.commailto:postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jugargentina.org - Co-Founder @ http://www.jbug.com.ar - Salatino Salaboy Mauricio - ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] [rules-user] problem with private members (no getters)
-Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of ehmkey Sent: 10 February 2012 11:18 To: rules-users@lists.jboss.org Subject: Re: [rules-users] [rules-user] problem with private members (no getters) I have a big switch case construction and i want to replace that with a rule based system. In the switch case are functions and they have parameters. Some of this parameters are private. The only idea i had was that i can create methods and call the methods with the rules. e.g the key of the switch-case is private, and i dont need and wont a getter for this [Swindells, Thomas] you need it if you are going to use it in rules in any sensible way, My advice is just to make a public getter and if necessary shove a big DO NOT USE in the javadoc. If you try you may be able to get away to limiting the scope to package as long as the rules file is also in the same package. Depending on how the objects are created/used in the rest of your application you may be able to write an interface to define the public methods and only your drools code uses/has access to the actualy implementation class Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Debugging
Use salience or some other order to control the facts. But I think the key point to remember is that Drools isn't stable, given the same set of rules and the same set of input in the same order there is no guarantee that the rules will execute in the same order unless there is something in the rules which forces them to do so. 99.9% of the time the version you run will produce the same ordered output but perhaps 0.1% of the time it could occur in a different order. This can lead to some nasty intermittent bugs if rules aren't written correctly and make implicit assumptions about the order they run. My suspicion is this is due to some hash map/set buried deep in the code somewhere controlling the order of equal priority activations, but I've never managed to work out where this is (if my theory is even correct). It would be nice if it were changed to a version that produces a consistent ordering every time (given the exact same set of inputs). Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Veera Sent: 09 February 2012 06:25 To: rules-users@lists.jboss.org Subject: [rules-users] Drools Debugging Hi All, I have one doubt that is : When i compiling a sample HelloWorld Drools program it is printing output like : Hello World Goodbye cruel world and i added a simple rule like : rule test when eval(true) then System.out.println( Hello!!! ); end When i compile the output is : Hello!!! Hello World Goodbye cruel world But when i debug it is showing output like: Hello World Goodbye cruel world Hello!!! Can anybody help me how to get the same output when i debug also... Regards, Veera -- View this message in context: http://drools.46999.n3.nabble.com/Drools- Debugging-tp3728574p3728574.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Low Date question in drools
One way would be to do dateOfBirth.time nn Where n is (new Date(-1900, 1,1)).getTime() By the way be very very wary of Date objects coming back from the database and check what the actual implementation class type is (and not the variable type). Even though java.sql.Timestamp extends java.util.Date they don’t mix. From the Javadocs Note: This type is a composite of a java.util.Date and a separate nanoseconds value. Only integral seconds are stored in the java.util.Date component. The fractional seconds - the nanos - are separate. TheTimestamp.equals(Object) method never returns true when passed an object that isn't an instance of java.sql.Timestamp, because the nanos component of a date is unknown. As a result, theTimestamp.equals(Object) method is not symmetric with respect to the java.util.Date.equals(Object) method. Also, the hashcode method uses the underlying java.util.Date implementation and therefore does not include nanos in its computation. Due to the differences between the Timestamp class and the java.util.Date class mentioned above, it is recommended that code not view Timestamp values generically as an instance of java.util.Date. The inheritance relationship between Timestamp and java.util.Date really denotes implementation inheritance, and not type inheritance. We had great fun tracking down issues in our rules caused by this – our fields were Date classes, but when fetched back from the database the instance type would be Timestamp. The rules worked fine in unit tests and first execution (as they were all new objects the type was java.util.Date) but not on subsequent executions when they were returned from the DB! Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Nancy Henggeler Sent: 09 February 2012 17:24 To: Rules Users List Subject: Re: [rules-users] Low Date question in drools It is a java date. We use some java binding objects to build it. Below is just a sampling of this. The second entry below indicates what to name it in Java, it's java type, what DB2 table (cogentTable) and data field it is coming from (cogentField). The snippets below might not help much. 1) bindHistory((ECDField) object.getElement(dateOfBirth), this.getDateOfBirthHistory()); 2)attribute name=dateOfBirth typeDate/type cogenTableW1V0/cogenTable cogenFieldBIRTH-DATE/cogenField descriptionDate Of Birth/description /attribute From:Wolfgang Laun wolfgang.l...@gmail.commailto:wolfgang.l...@gmail.com To:Rules Users List rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org Date:02/09/2012 11:00 AM Subject:Re: [rules-users] Low Date question in drools Sent by: rules-users-boun...@lists.jboss.orgmailto:rules-users-boun...@lists.jboss.org So what is the Java type of dateOfBirth, please? -W 2012/2/9 Nancy Henggeler nancy.hengge...@fblfinancial.commailto:nancy.hengge...@fblfinancial.com Hello Laun, Thank you for your quick response. This date is a date coming from a DB2 date field and is valid in my incoming data. Frankly, I am with you, why not null versus a silly low date as such, arh. But since it is coming in as such do you know of a work around? Thank so much, Nancy From:Wolfgang Laun wolfgang.l...@gmail.commailto:wolfgang.l...@gmail.com To:Rules Users List rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org Date:02/09/2012 10:31 AM Subject:Re: [rules-users] Low Date question in drools Sent by: rules-users-boun...@lists.jboss.orgmailto:rules-users-boun...@lists.jboss.org Why would you want to test for January 1st in year 1? This is not a value an object of type java.util.Date can represent. See that type's javadoc for details, but the epoch begins January 1, 1970. -W On 9 February 2012 17:19, Nancy Henggeler nancy.hengge...@fblfinancial.commailto:nancy.hengge...@fblfinancial.com wrote: I have a simple rule where I want to bypass elements that have a low date but drools seems to be interpreting the date different then I am expecting. Drools statement and error follows: ClientSupplement ( dateOfBirth : dateOfBirth != null != 0001-01-01) throws error -- Error: [Error: badly formatted number: For input string: 001-01-01] [Near : {... 0001-01-01 }] ^ [Line: 1, Column: 1] How do I get drools to understand this low date? I have tried single, double, and no quotes around the low date and all result in a similiar error message. Please Help! -- View this message in context: http://drools.46999.n3.nabble.com/Low-Date-question-in-drools-tp3729940p3729940.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing
Re: [rules-users] How to write rules in two fact's fields?
I'd assume the intention was to use the support mvel provides for abbreviating expressions - so it is intended to be interpreted as shorthand for 20 = price price 30. I'm not 100% sure scanning through the docs whether this form is correct or not. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 05 February 2012 12:22 To: Rules Users List Cc: Rules Dev List Subject: Re: [rules-users] How to write rules in two fact's fields? In most programming languages the result of (e.g.) an integer comparison 20 = price is a value of a different type, i.e., boolean, with values true or false. (You have heard this at some time, right?) Consequently, the comparison of a boolean with an integer true 30 depends on whether the language tolerates it, and if so, how that result is defined. IT IS A BUG THAT DROOLS TOLERATES (BUT DOES NOT DEFINE) SUCH MULTIPLE COMPARISONS BUT DOES NOT FLAG THEM AS AN ERROR OR IMPLEMENT THEM IN SOME WAY. (Tested with 5.3.0 Final.) This means that you'll have to rwrite your constraints using or ||, as appropriate. -W On 05/02/2012, shanmuga shanmugasundaram@gmail.com wrote: Hi, I want to know, how to write rules in two fact's fields? I used two facts, it will take AND condition or OR condition in between the two facts. Please check my code package Project import com.sample.Person; import com.sample.Price; rule rule_Name when per:*Person*(50 = age 100, 1 = income 5, occupation == Business, category == Military, location == Bangalore, custype == Individual) pri:*Price*((20 = price 30) || price == 1) then System.out.println(Success); end The both fact values are satisfy means, what is the output? I got output, even the *Price* fact's value is wrong. (price == 100) Please slove my problem -- View this message in context: http://drools.46999.n3.nabble.com/How-to-write-rules-in-two-fact-s-fie lds-tp3717063p3717063.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to use the xls file as decision table?
Write a java program that loads and use the spreadsheet - in the same way that you use would do so for a DRL file. The eclipse plugin is just an environment to help development and testing, it doesn't actually run anything - Afterall having rules is just half the picture, you also need to insert facts. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of ponmanirajan Sent: 31 January 2012 13:16 To: rules-users@lists.jboss.org Subject: [rules-users] How to use the xls file as decision table? I create an xls file as follows, http://drools.46999.n3.nabble.com/file/n3703234/xlsData.jpg how to use this decision table in drools eclipse plugin? thanks in advance. -- View this message in context: http://drools.46999.n3.nabble.com/How-to-use- the-xls-file-as-decision-table-tp3703234p3703234.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to enable logging in my application?
You need a log4j.properties file on your classpath, if you search for configuring log4j in google you should find advice on how to initialize log4j properly. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of aitchnyu Sent: 30 January 2012 11:05 To: rules-users@lists.jboss.org Subject: [rules-users] How to enable logging in my application? I want to enable logging in my application. Since Drools planner uses log4j, how can I enable it's logging in my application? In the current form, my application runs as: jesvin@Jesvin-Technovia:~/dev/drools/sudoku$ java in.co.technovia.sudoku.App log4j:WARN No appenders could be found for logger (org.drools.planner.core.solver.DefaultSolver). log4j:WARN Please initialize the log4j system properly. -- View this message in context: http://drools.46999.n3.nabble.com/How-to- enable-logging-in-my-application-tp3699696p3699696.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Code Coverage
It depends what you are asking for, If you just want to know what proportion of rules you have written have actually activated then that can be simply achieved by having a AgendaEventListener and using it to 'tick' rules off when they have been triggered - the blog entry should have you achieve this. If you actually want to integrate it with standard java code coverage reports then this is a different question and is likely to be much harder, if not impossible, Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of mike Sent: 23 January 2012 14:34 To: Rules Users List Subject: Re: [rules-users] Code Coverage Thank you very much ... as far as i know in order to do code coverage i need to instrument the packages i'm interested in covering ... this recommendation doesn't take me in that direction It is very useful however in showing a way to test rules individually. Thank you Mike 2012/1/17 Toni Rikkola toni.rikk...@gmail.commailto:toni.rikk...@gmail.com You need to write the coverage tests for JUnit yourself. Test Scenarios in Guvnor do this, but you can't use them outside Guvnor. Test Scenarios get all the rule names for the rules in one package and then compares that list to the rules that fired. Edson's blog entry might help you http://blog.athico.com/2011/10/cookbook-how-to-test-rules-using-xunit.html. Toni On Jan 16, 2012, at 5:49 PM, mike wrote: Hi there, I was wondering if its possible to measure code coverage on test running against a set of rules. Thank you Mike ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Code Coverage
There is nothing stopping you taking the output and producing a report in your CI showing lines (Rules) in red and green as to whether they have been touched as part of the tests - if you separate out your rules into a separate module you could probably output the report in the exact same format as the standard java report xml and get the standard tools to output an almost identical report. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of mike Sent: 23 January 2012 16:14 To: Rules Users List Subject: Re: [rules-users] Code Coverage I could argue this left and right with my managers ... but in reality when we mention code coverage we mean looking at a report in CI showing lines of code in green or red ... anything short of that is something else Thank you very much for the response Cheers Mike On Mon, Jan 23, 2012 at 10:47 AM, Wolfgang Laun wolfgang.l...@gmail.commailto:wolfgang.l...@gmail.com wrote: It is highly recommended as best practice to have RHS code that doesn't contain any branching instructions. Then, executing means full coverage. In case it is necessary to have more complex code I'd not put it into a RHS anyway (where it isn't really OO any more) but I'd code it in Java files and just call from the RHS. For the LHS you can also argue that firing proves coverage; although it won't be full *expression* logic coverage, due to potentially skipped subexpressions in disjunctions. -W On 23/01/2012, mike mike...@gmail.commailto:mike...@gmail.com wrote: Thank you very much Thomas ... yes, what i need is standard code coverage ... my company is all over that metric cheers Mike 2012/1/23 Swindells, Thomas tswinde...@nds.commailto:tswinde...@nds.com It depends what you are asking for, If you just want to know what proportion of rules you have written have actually activated then that can be simply achieved by having a AgendaEventListener and using it to 'tick' rules off when they have been triggered - the blog entry should have you achieve this. ** ** If you actually want to integrate it with standard java code coverage reports then this is a different question and is likely to be much harder, if not impossible, ** ** Thomas ** ** *From:* rules-users-boun...@lists.jboss.orgmailto:rules-users-boun...@lists.jboss.org [mailto: rules-users-boun...@lists.jboss.orgmailto:rules-users-boun...@lists.jboss.org] *On Behalf Of *mike *Sent:* 23 January 2012 14:34 *To:* Rules Users List *Subject:* Re: [rules-users] Code Coverage ** ** Thank you very much ... as far as i know in order to do code coverage i need to instrument the packages i'm interested in covering ... this recommendation doesn't take me in that direction ** ** It is very useful however in showing a way to test rules individually. ** ** Thank you Mike ** ** 2012/1/17 Toni Rikkola toni.rikk...@gmail.commailto:toni.rikk...@gmail.com You need to write the coverage tests for JUnit yourself. Test Scenarios in Guvnor do this, but you can't use them outside Guvnor. ** ** Test Scenarios get all the rule names for the rules in one package and then compares that list to the rules that fired. Edson's blog entry might help you http://blog.athico.com/2011/10/cookbook-how-to-test-rules-using-xunit.html . ** ** Toni ** ** On Jan 16, 2012, at 5:49 PM, mike wrote: ** ** Hi there, ** ** I was wondering if its possible to measure code coverage on test running against a set of rules. ** ** Thank you Mike ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** ** ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** ** -- ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.commailto:postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users
Re: [rules-users] Can we set a default value for emlpty cells in Drools templates
There isn't a nice way to do this unfortunately. One hack around it is to have two columns with the object merged across them The first column would have the condition $a : Company(this != $param), every cell in the column is then given the value 'null'. This would then always ensure that $a will always exist. The second column can then be written as normal with your optional condition. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of swaroop Sent: 20 January 2012 08:34 To: rules-users@lists.jboss.org Subject: [rules-users] Can we set a default value for emlpty cells in Drools templates Hi, I am trying to write a template and came across a scenario where one of the condition cell $a : Company(condition), When condition is left blank then entire predicate is missed and iam using the ref of the company obj $a to set some values which is failing as the declaration part is missing, So i was thinking, if we can have a default value to the cell as $a : Company(), then the scenario will be handled.Kindly let me know how to implement the default value for a cell in template to overcome the above mentioned scenario Thanks Swaroop -- View this message in context: http://drools.46999.n3.nabble.com/Can-we- set-a-default-value-for-emlpty-cells-in-Drools-templates- tp3674849p3674849.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rules Evaluation based on agenda
The best solution is to only insert the rulse you actually want into the knowledge base. Another option may be not to use agenda groups (or just agenda groups) but have a control fact as the first condition of all your rules eg when UseCase(name ==abc) ... Then Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Vis Sent: 20 January 2012 09:34 To: rules-users@lists.jboss.org Subject: [rules-users] Rules Evaluation based on agenda Hi, We have many agenda-group based rules defined in application and while firing rules, we set specifc agend group based on different use cases to the session. In evaluation phase of rules, it not only evaluate rules related with agenda set to the session but also other rules which are not belong to the same agenda which is set to the session. Now problem here is: since some time we get error, if a inserted fact is used in other agenda group and their nested objects are not initialized which are used in condition, it throws errors and exit. if Drools could provide filtering capablitiy at evaluation time like wise AgendaFilter is provided to filter activated rules, it will be great. If there is any workaround it will be a great help. Thanks in advance -V -- View this message in context: http://drools.46999.n3.nabble.com/Rules- Evaluation-based-on-agenda-tp3674950p3674950.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Infinit loop in simple example
The simplist solution is just to change your condition to be $a : Applicant(age 18, valid != false) Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Esteban Aliverti Sent: 20 January 2012 14:20 To: Rules Users List Subject: Re: [rules-users] Infinit loop in simple example import spikes.Applicant rule Is of valid age when $a : Applicant( age 18 ) then modify( $a ) { valid = false }; end By using modify() you are telling the engine that $a was modified in some way. This causes the re-evaluation of your rule, and since $a.age is still 18, then the rule is activated and fired infinite times. Read the documentation manual about some attributes you can use in your rules to avoid this behavior: no-loop, lock-on-active. Best Regards, Esteban Aliverti - Developer @ http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com On Fri, Jan 20, 2012 at 3:12 PM, roland.kofler roland.kof...@gmail.commailto:roland.kof...@gmail.com wrote: Simple example loops ad infinitum if executed: package spikes; import org.springframework.roo.addon.javabean.RooJavaBean; @RooJavaBean public class Applicant { private final String string; private final int age; public boolean valid=true; public Applicant(String string, int i) { this.string = string; this.age = i; } } DroolsSpikeTest package spikes; import static org.junit.Assert.*; import org.drools.KnowledgeBase; import org.drools.runtime.StatelessKnowledgeSession; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={classpath:**/applicationContext-drools.xml}) public class DroolsSpikeTest { @Autowired private KnowledgeBase kbase; @Test public void testspikeDroolRule() { StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(); Applicant a = new Applicant(Mr John Smith, 16); assertTrue(a.isValid()); ksession.execute(a); assertFalse(a.isValid()); } } applicationContext-drools.xml ?xml version=1.0 encoding=UTF-8 standalone=no? beans xmlns=http://www.springframework.org/schema/beans; xmlns:aop=http://www.springframework.org/schema/aop; xmlns:context=http://www.springframework.org/schema/context; xmlns:jee=http://www.springframework.org/schema/jee; xmlns:tx=http://www.springframework.org/schema/tx; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:drools=http://drools.org/schema/drools-spring; xsi:schemaLocation=http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://drools.org/schema/drools-spring http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd; drools:kbase id=kbase1 drools:resources drools:resource id=licenseRule type=DRL source=classpath:spikes/licenseApplication.drl/ /drools:resources drools:configuration drools:mbeans enabled=true / /drools:configuration /drools:kbase drools:ksession kbase=kbase1 type=stateless id=ksessionStateless name=stateless1 /drools:ksession /beans licenseApplication.drl import spikes.Applicant rule Is of valid age when $a : Applicant( age 18 ) then modify( $a ) { valid = false }; end -- View this message in context: http://drools.46999.n3.nabble.com/Infinit-loop-in-simple-example-tp3675536p3675536.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom.
Re: [rules-users] Groovy classes as fact classes in drool
It can't find the class groovy.lang.GroovyObject, looks like you need to deploy the groovy jars into guvnor/tomcat so that they are available. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of kavita Sent: 18 January 2012 18:55 To: rules-users@lists.jboss.org Subject: [rules-users] Groovy classes as fact classes in drool Hi, Can anybody tell me how to use groovy classes as fact classes in drools. When i try to upload the jar file generated from the groovy class am getting the following error: SEVERE: Servlet.service() for servlet AssetFileServlet threw exception java.lang.ClassNotFoundException: groovy.lang.GroovyObject at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoad er.java:1680) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoad er.java:1526) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.drools.rule.MapBackedClassLoader.loadClass(MapBackedClassLoader.jav a:109) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(Unknown Source) at java.lang.ClassLoader.defineClass(Unknown Source) at org.drools.rule.MapBackedClassLoader.fastFindClass(MapBackedClassLoader .java:86) at org.drools.rule.MapBackedClassLoader.loadClass(MapBackedClassLoader.jav a:104) at java.lang.ClassLoader.loadClass(Unknown Source) at org.drools.guvnor.server.contenthandler.ModelContentHandler.isClassVisibl e(ModelContentHandler.java:183) at org.drools.guvnor.server.contenthandler.ModelContentHandler.getImports FromJar(ModelContentHandler.java:148) at org.drools.guvnor.server.contenthandler.ModelContentHandler.onAttachm entAdded(ModelContentHandler.java:66) at org.drools.guvnor.server.files.FileManagerUtils.attachFileToAsset(FileManag erUtils.java:115) at org.drools.guvnor.server.files.FileManagerUtils.attachFile(FileManagerUtils.j ava:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.jboss.seam.util.Reflections.invoke(Reflections.java:22) at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationCo ntext.java:32) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationC ontext.java:56) at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterc eptor.java:28) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationC ontext.java:68) at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor .java:77) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationC ontext.java:68) at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodCon textInterceptor.java:44) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationC ontext.java:68) at org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityIntercept or.java:163) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationC ontext.java:68) at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBean Interceptor.java:185) at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.j ava:103) at org.drools.guvnor.server.files.FileManagerUtils_$$_javassist_seam_10.attac hFile(FileManagerUtils_$$_javassist_seam_10.java) at org.drools.guvnor.server.files.AssetFileServlet.processAttachFileToAsset(Ass etFileServlet.java:97) at org.drools.guvnor.server.files.AssetFileServlet.doPost(AssetFileServlet.java: 49) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFi lterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChai n.java:206) at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42) at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpSe rvletRequest.java:65) at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFi lterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChai n.java:206) at
Re: [rules-users] For loop inside a modify block problem
You could try assigning $item to a local variable and then using that within the for loop? Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Martin A Sent: 11 January 2012 10:02 To: Rules Users List Subject: Re: [rules-users] For loop inside a modify block problem hi Michael, All of the fields are public, however they are properties of a super class of Item. I tried with getters, doesn't work either way. Still getting: 'no such identifier : $item'. When I remove the for loop, it goes ok, so I think it messes up things. Best regards, Martin 2012/1/11 Michael Anstis michael.ans...@gmail.commailto:michael.ans...@gmail.com RHS is not DRL syntax but Java or MVEL depending on your dialect. If id is not public you should use it's getter. The same goes for quantity. when $item : Item(param1 != 0, param2 == 0, !(this instanceof SpecialItem)) $gsc : SomeBusinessLogic then $gsc.doSomething($item.getId() ); for (int i = 0; i $item.getQuantity(); i++) { $gsc.doSomethingElse($item.getId() ); } update($gsc); end 2012/1/11 Martin A wml...@gmail.commailto:wml...@gmail.com Hi, Davide, Here is how my rule looks like : when $item : Item(param1 != 0, param2 == 0, !(this instanceof SpecialItem)) $gsc : SomeBusinessLogic then $gsc.doSomething($item.idhttp://item.id/); for (int i = 0; i $item.quantity; i++) { $gsc.doSomethingElse($item.idhttp://item.id/); } update($gsc); end The above snippet throws an error @ i $item.quantity, and says 'no such identifier $item'... I can't figure out what might be causing this. Thanks On Tue, Jan 10, 2012 at 10:08 PM, Davide Sottara dso...@gmail.commailto:dso...@gmail.com wrote: Did you remember to bind $item to some expression in the LHS ? Maybe you just called that item without the $ :) Davide (the original modify syntax is still wrong anyway) -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-For-loop-inside-a-modify-block-problem-tp3648460p3648718.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] For loop inside a modify block problem
From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mark Proctor Sent: 11 January 2012 15:27 To: rules-users@lists.jboss.org Subject: Re: [rules-users] For loop inside a modify block problem Why no braces after SomeBusinessLogic? Also your logic is wrong there. Item is not a collection so your for loop is repeating the same action over and over again for the same data. [Swindells, Thomas] It does look like that but it depends what the action is. Perhaps it is integrating with a rubbish stock system which can only remove one item at a time, to remove n identical items you have to call it n times. Mark On 11/01/2012 09:27, Martin A wrote: Hi, Davide, Here is how my rule looks like : when $item : Item(param1 != 0, param2 == 0, !(this instanceof SpecialItem)) $gsc : SomeBusinessLogic then $gsc.doSomething($item.idhttp://item.id/); for (int i = 0; i $item.quantity; i++) { $gsc.doSomethingElse($item.idhttp://item.id/); } update($gsc); end The above snippet throws an error @ i $item.quantity, and says 'no such identifier $item'... I can't figure out what might be causing this. Thanks On Tue, Jan 10, 2012 at 10:08 PM, Davide Sottara dso...@gmail.commailto:dso...@gmail.com wrote: Did you remember to bind $item to some expression in the LHS ? Maybe you just called that item without the $ :) Davide (the original modify syntax is still wrong anyway) -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-For-loop-inside-a-modify-block-problem-tp3648460p3648718.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] NullPointerException when load file rules
Looking at the stack trace, if you are on the same version as drools as me it looks like it is this line this.rule.setDialect( getDialect().getId() ); The most likely reason is your DRL isn't valid - perhaps where you are specifying the dialect, or it could be your Dependencies aren't right or something. Which version of drools are you using. Have you tried reducing your DRL file to the minimum that generates the error - then post that DRL if you need further help. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of jjmartinez Sent: 10 January 2012 17:05 To: rules-users@lists.jboss.org Subject: Re: [rules-users] NullPointerException when load file rules Anybody can help me? I don't know why my application show these errors. Thanks in advance! java.lang.NullPointerException at org.drools.rule.builder.RuleBuildContext.init(RuleBuildContext.java:88) at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1149) at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:636) at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:266) at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:458) at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28) at drools.ejemplos.DroolsTest.readKnowledgeBase(DroolsTest.java:85) at drools.ejemplos.DroolsTest.execute(DroolsTest.java:64) at drools.ejemplos.DroolsTest.init(DroolsTest.java:56) at drools.ejemplos.Activator.start(Activator.java:14) at org.knopflerfish.framework.BundleImpl.start0(BundleImpl.java:356) at org.knopflerfish.framework.BundleThread.run(BundleThread.java:107) ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Resource Change Scanner Service modified date error
As well as the message not making sense the exception should also really be UnsupportedOperationException, of course the preference is for someone to implement it and make it supported! Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Esteban Aliverti Sent: 06 January 2012 09:14 To: Rules Users List Subject: Re: [rules-users] Resource Change Scanner Service modified date error Could you please share with us how are you adding your resources to the agent? According to what you are saying I assume you are using a ReaderResource. According to Drools code, ReaderResource doesn't support most of org.drools.io.internal.InternalResource methods. Some of these methods (i.e. getLastModified()) are used by ResourceScanner to check if a resource has actually changed. So if we take a look at ReaderResource.getLastModified() we will see this: public long getLastModified() { throw new IllegalStateException( reader does have a modified date ); } You can find the whole source code here: https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/io/impl/ReaderResource.java So, don't expect this to work :) There are 2 things you can do: 1. Submit a patch for ReaderResource.java implementing all the unimplemented methods :) 2. Use a different Resource like UrlResource, FileResource, InputStreamResource, etc. In my opinion, Bug 733008 must be reopened until someone (maybe you Dean) provides a correct implementation of ReaderResource. Best Regards, Esteban Aliverti - Developer @ http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com On Fri, Jan 6, 2012 at 8:53 AM, Dean d...@qualica.commailto:d...@qualica.com wrote: I'm pretty sure this issue is the same as Bug 733008 (https://bugzilla.redhat.com/show_bug.cgi?id=733008). I have updated the class from Bug 733008 to reproduce the bug in Drools 5.4.0.Beta1: http://drools.46999.n3.nabble.com/file/n3637279/AgentTest.java AgentTest.java It doesn't seem to be possible to scan a resource for changes at all. Even if I execute ResourceFactory.getResourceChangeScannerService().scan(); directly, I get the same error message: [2012-01-06 09tel:%5B2012-01-06%2009:47:57,144:exception] java.lang.IllegalStateException: reader does have a modified date at org.drools.io.impl.ReaderResource.getLastModified(ReaderResource.java:64) at org.drools.io.impl.ResourceChangeScannerImpl.scan(ResourceChangeScannerImpl.java:166) at org.drools.io.impl.ResourceChangeScannerImpl$ProcessChangeSet.run(ResourceChangeScannerImpl.java:311) at java.lang.Thread.run(Thread.java:662) (As a side note the error message should probably read: reader does /not/ have a modified date) Regards Dean -- View this message in context: http://drools.46999.n3.nabble.com/Resource-Change-Scanner-Service-modified-date-error-tp3634802p3637279.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Inserting rules from guvnor into database
What is your actual requirement? Guvnor already stores the rules in a database - derby by default, but you could probably configure postgres/mysql as the backend if you want. This page seems to have some details on that http://www.integratingstuff.com/2011/01/28/setting-up-drools-guvnor/ Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of srinivasasanda Sent: 04 January 2012 14:55 To: rules-users@lists.jboss.org Subject: [rules-users] Inserting rules from guvnor into database Hi All, Greetings, I would like to know how to insert the rules from guvnor into database.Ofcourse,I retrieved the rules from guvnor through KnowledgePackage classes and API and inserted manually through java code. But,I should not need that.My requirement is whenever i created rule in the guvnor and click save changes,my repository of rules must be inserted into database(mysql or postgres).How can i achieve that.Please suggest me.How can i achieve that. Thanks in Advance -- View this message in context: http://drools.46999.n3.nabble.com/Inserting- rules-from-guvnor-into-database-tp3632054p3632054.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Removing Special Characters
It will work but it isn't at all declarative but instead very procedural - it is effectively the same as retrieving all the rows from the database and then filtering them yourself. You've also failed to inform drools that you have updated the CustomerInfo object. Assuming customerName is a string in terms of java code it is also extremely inefficient and verbose (and badly broken as data isn't defined). String has the replace and replaceAll methods to replace characters far more efficiently than the approach below. I'd probably have something like Rule Wild char validation When c: CustomerInfo(name : customerName matches .*([\*#].*) //any string containing a * or a # then modify(c) { setCustomerName(name.replaceAll([\*#], )); //replace any * or # with } end if you don't like regex you could also do Rule Wild char validation When c: CustomerInfo(eval(customerName.contains(*) || customerName.contains(#))) //any string containing a * or a # then String name = c.getCustomerName(); name = name.replace(#,); name = name.replace(*,); modify(c) { setCustomerName(name); } end other similar variations are available - depending on your throughput you may want to experiment with whether there are many differences in terms of performance. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Lalitha Sent: 03 January 2012 12:02 To: rules-users@lists.jboss.org Subject: [rules-users] Removing Special Characters Hi all, I am working on drools. I would like to remove Special characters which are existed in the data i.e. replacing special characters with null. Following is the code: rule Wild Character validation when c : CustomerInfo(customerName != ); then int l = c.length(); int ch = 0; int i = 0; for (i = 0; i l; i++) { if (data.charAt(i) != *|| data.charAt(i) != #){ continue; } ch++; data.setCharAt(i, ); } c.setCustomerName(data); end Is there any wrong in this code? If so please help me out. Waiting for your suggestion . Thanks and Regards, Lalitha. -- View this message in context: http://drools.46999.n3.nabble.com/Removing- Special-Characters-tp3628821p3628821.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Removing Special Characters
Good points - hopefulyl the gist of what I was suggesting came across - I like to leave debugging what I spew out as an exercise for the reader From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 03 January 2012 14:28 To: Rules Users List Subject: Re: [rules-users] Removing Special Characters On 3 January 2012 14:49, Swindells, Thomas tswinde...@nds.commailto:tswinde...@nds.com wrote: It will work Not the way it was posted. At least, StringBuffer.setCharAt() needs a second argument of type char, and this would be a strange type for a customer name field. Rule Wild char validation When c: CustomerInfo(name : customerName matches .*([\*#].*) //any string containing a * or a # There's a syntax error here, use .*[*#].*, because you don't need to quote '*' inside '[...]', and if you do (which is OK) you'll have to use '\\'. then modify(c) { setCustomerName(name.replaceAll([\*#], )); //replace any * or # with } end Same here: either no '\' or doubled. -W ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] [rules-dev] Drools 5.4.0.Beta1 released
The link http://blog.athico.com/2011/12/new-feature-spotlight-traits-part-1.htmlhttp://docs.jboss.org/drools/release/5.4.0.Beta1/droolsjbpm-introduction-docs/html/releaseNotesBeta1.html??? in the release notes actually points back to the release notes not to the url it is meant to. The rest of the links look fine though, Thomas From: rules-dev-boun...@lists.jboss.org [mailto:rules-dev-boun...@lists.jboss.org] On Behalf Of Toni Rikkola Sent: 20 December 2011 11:20 To: Rules Dev List; Rules Users List Subject: [rules-dev] Drools 5.4.0.Beta1 released Drools 5.4.0.Beta1 released (Expert, Fusion, Planner, Guvnor) New and Noteworthy: http://docs.jboss.org/drools/release/5.4.0.Beta1/droolsjbpm-introduction-docs/html/releaseNotesBeta1.html Download and info: http://blog.athico.com/2011/12/drools-540beta1-released.html Toni Rikkola ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table multiple sheets...
We have the following code to load multiple sheets from a single xls - it's more involved than I would like and I'd agree with the sentiment that drools should load all the sheets not just the first one. It's brutely pulled from out codebase so I'll leave it as an exercise to the reader to tidy it up for your usage, Thomas protected File loadXLS(KnowledgeBuilder kbuilder, MapString, String compiledFiles, File xls) throws KnowledgeBaseLoadException { log.info(Loading spreadsheet from {}, xls.getAbsolutePath()); DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration(); dtconf.setInputType(DecisionTableInputType.XLS); SpreadsheetCompiler compiler = new SpreadsheetCompiler(); Workbook w; String sheetName = ; FileInputStream in = null; try { w = Workbook.getWorkbook(xls); for (Sheet sheet : w.getSheets()) { in = new FileInputStream(xls); sheetName = sheet.getName(); log.info(Compiling sheet {} from {}, sheetName, xls.getAbsolutePath()); compileSheet(kbuilder, compiledFiles, xls, compiler, sheetName, in); IOUtils.closeQuietly(in); } } catch (DecisionTableParseException e) { throw new KnowledgeBaseLoadException(Failed to parse spreadsheet + sheetName, e); } //CHECKSTYLE:OFF //Need to catch the DecisionTableParseException exception catch (RuntimeException e) { throw new KnowledgeBaseLoadException(Failed to import decision table + sheetName, e); } //CHECKSTYLE:OFN catch (BiffException e) { throw new KnowledgeBaseLoadException(Failed to read spreadsheet: + e.getMessage(), e); } catch (IOException e) { throw new KnowledgeBaseLoadException(Failed to read spreadsheet: + e.getMessage(), e); } finally { IOUtils.closeQuietly(in); } } private void compileSheet(KnowledgeBuilder kbuilder, MapString, String compiledFiles, File xls, SpreadsheetCompiler compiler, String sheetName, FileInputStream in) { try { String compiled = compiler.compile(in, sheetName); log.debug(Sheet {} compiled to:\n{}, sheetName, compiled); compiledFiles.put(xls.getName() + # + sheetName, compiled); kbuilder.add(ResourceFactory.newReaderResource(new StringReader(compiled)), ResourceType.DRL); } catch (DecisionTableParseException dtpe) { // TODO fix dirty hack ... multi sheet support should be moved into drools if (dtpe.getMessage().equals(No RuleTable's were found in spreadsheet.)) { log.info(No rule tables found in sheet {}, sheetName); } else { throw dtpe; } } } -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 21 December 2011 10:38 To: Rules Users List Subject: Re: [rules-users] Decision table multiple sheets... By definition (see the Expert manual) only sheet 1 is used for generating rules. For controlling rule firing you may consider using any of the rule attributes supported by spreadsheets, e.g., agenda-group. -W On 21/12/2011, Sumeet Karawal sumeet.kara...@tcs.com wrote: Hi, I am having my rules in a Decision Table (.xls) There I have 3 sheets for rules. Like in Sheet1 there are two Rule Tables... In Sheet2 there are 2 and in Sheet3 there is only 1. When I am creating the knowledgebase and firing rules, the rules that are in the Sheet1 are getting fired. But the rules in other sheets are not getting fired. When I convert them to String to check using this code : String str = DecisionTableFactory.loadFromInputStream (ResourceFactory.newClassPathResource
Re: [rules-users] Problems with Domain Specific Language in eclipse
Personally - I would rather get an error when I make a mistake (e.g. do not write the DSL correctly) than get get an error for writing perfectly valid code. [Swindells, Thomas] But it isn't valid DSL code. DSL is normally written by business users who don't know anything about DRL, this is the target audience and for these people you don't want them to be able to accidentally do additional logic. Eclipse does support a DSL expansion window which allows you to find issues like misspellings. The current approach requires a total commitment to DSL even if you want to use it under rare circumstances. I did note your suggestion about prefixing with '', but then my RHS looks different in rule files where I use DSL than it does in files where I do not use DSL (something I would rather avoid). Your entire file looks different in DSL than in a DRL anyway, it's a different language that allows embedding DRL, personally I think it is a good feature to explicitly need to identify that you know what you are doing. Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Can Drools supply large Knowledge Base?
I think you are mixing up terms which doesn't help. I think you mean you may have 100GB of facts that will be in your distributed database. Unless you are planning to do some odd automatic rule generation you will have to write the rules by hand and so will only have a relatively small number of rules in your application - this will easily fit in memory. If 100GB is the size of the facts you have then clearly you can't hold them all in memory of a single machine. Drools is effectively a special in memory database, in order to perform its processing it needs the relevant data. You basically have these options which of these will work depends on your use case and in reality you'll probably need to combine them: 1. Use partitioning, rather than having 1 set of 100 gb of data, have 10 sets of 10 gbs running on ten machines. Many times you may be able to partition by customer ID or some other natural value which may give you good enough results. 2. Use accumulating facts and only keep the data you need in memory, eg if you need to know how many orders a customer has made then don't keep all the orders in memory, just a simple object containing the total. 3. Don't use drools, depending on what you are doing it may be better just to use normal db queries to extract the data you need. It may be you get the query results, insert them into a new short lived session, fire the rules and then get the results of the drools processing. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of WangRamon Sent: 12 December 2011 09:11 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Can Drools supply large Knowledge Base? Hi Guys I'm still confused about this question, let's say i may have a very large rule set, how can Drools support this case, will it load every rule into memory? Any idea? Thank you guys. Cheers Ramon From: ramon_w...@hotmail.com To: rules-users@lists.jboss.org Date: Thu, 8 Dec 2011 11:59:21 +0800 Subject: [rules-users] Can Drools supply large Knowledge Base? Hi All I'm new to Drools, I will build a very large Knowledge Base, let's say it will be larger than 100GB, the files will be stored in a distribute database, so can Droools supply this large Knowledge Base? Any solution? Thank you very much. Cheers Ramon ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Can Drools supply large Knowledge Base?
There's not that much to say - and if you do a search you should find more information. Basically only have the information that you need in memory. If you need to make calculations of previous state, rather than keeping the previous state all loaded up just have facts which record the state - perhaps an OrderTotal fact which contains the total of all the orders. When a new order arrives you update the value of that. It all depends on what you are trying to achieve and what you are doing. Without a concrete understanding of what sort of problem you are trying to solve and what you are planning to do we can't give much more guidance beyond that there are various different solutions and approaches that are appropriate for various different problem spaces. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of WangRamon Sent: 12 December 2011 09:50 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Can Drools supply large Knowledge Base? Thanks Thomas! The solutions you provided are great, can you give more explanation on your second point Use accumulating facts and only keep the data you need in memory, thanks. Cheers Ramon From: tswinde...@nds.com To: rules-users@lists.jboss.org Date: Mon, 12 Dec 2011 09:24:14 + Subject: Re: [rules-users] Can Drools supply large Knowledge Base? I think you are mixing up terms which doesn't help. I think you mean you may have 100GB of facts that will be in your distributed database. Unless you are planning to do some odd automatic rule generation you will have to write the rules by hand and so will only have a relatively small number of rules in your application - this will easily fit in memory. If 100GB is the size of the facts you have then clearly you can't hold them all in memory of a single machine. Drools is effectively a special in memory database, in order to perform its processing it needs the relevant data. You basically have these options which of these will work depends on your use case and in reality you'll probably need to combine them: 1. Use partitioning, rather than having 1 set of 100 gb of data, have 10 sets of 10 gbs running on ten machines. Many times you may be able to partition by customer ID or some other natural value which may give you good enough results. 2. Use accumulating facts and only keep the data you need in memory, eg if you need to know how many orders a customer has made then don't keep all the orders in memory, just a simple object containing the total. 3. Don't use drools, depending on what you are doing it may be better just to use normal db queries to extract the data you need. It may be you get the query results, insert them into a new short lived session, fire the rules and then get the results of the drools processing. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of WangRamon Sent: 12 December 2011 09:11 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Can Drools supply large Knowledge Base? Hi Guys I'm still confused about this question, let's say i may have a very large rule set, how can Drools support this case, will it load every rule into memory? Any idea? Thank you guys. Cheers Ramon From: ramon_w...@hotmail.com To: rules-users@lists.jboss.org Date: Thu, 8 Dec 2011 11:59:21 +0800 Subject: [rules-users] Can Drools supply large Knowledge Base? Hi All I'm new to Drools, I will build a very large Knowledge Base, let's say it will be larger than 100GB, the files will be stored in a distribute database, so can Droools supply this large Knowledge Base? Any solution? Thank you very much. Cheers Ramon ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.commailto:postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org
Re: [rules-users] Can Drools supply large Knowledge Base?
That's not a big rule, that is a tiny rule. So I'm still not sure what you are actually worrying about and why you think you may have an issue. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of WangRamon Sent: 12 December 2011 09:44 To: rou...@di.uoa.gr; rules-users@lists.jboss.org Subject: Re: [rules-users] Can Drools supply large Knowledge Base? Hi Stathis You're probably right, maybe it's a wrong question, i'm new to Drools, so I copy the rule sample from user guide as below to better explain, that's what i need, but the rule will be automatically generated in the future.. package com.company.license rule Is of valid age when $a : Applicant( age 18 ) then $a.setValid( false ); end So in the future the rule may include more and more conditions like below: rule Is of valid age2 when $a : Applicant( age 18 and age 20 ) then ... end So it may grow to be a very large rule(?), and this is actually my question: how to handle this big rule? Thanks you guys Cheers Ramon Date: Mon, 12 Dec 2011 11:33:10 +0200 From: rou...@mm.di.uoa.grmailto:rou...@mm.di.uoa.gr To: rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org Subject: Re: [rules-users] Can Drools supply large Knowledge Base? WangRamon wrote: Hi Guys I'm still confused about this question, let's say i may have a very large rule set, how can Drools support this case, will it load every rule into memory? Any idea? Thank you guys. CheersRamon You are either asking the wrong question or you do not understand what you are asking. In your previous post, you mentioned a Knowledge Base of 100GB. In this post you are talking about a rule set. These are different things. A Knowledge Base contains rules *and* facts and can indeed be quite large. A rule set contains only rules. For a rule set to grow this much, it means you have seriously misunderstand your problem. I would suggest you go back to the drawing board. Real-world example: Rule set of about 400 rules. Facts : In the order to 100.000. Command line execution shows an approximate 400MB RAM consumption, meaning with the JDK and all (not only Drools memory consumption). So, unless you want to hear from someone more experienced than me, I'd suggest you re-phrase your question by stating the exact problem you are facing or anticipating. Cheers, -Stathis From: ramon_w...@hotmail.commailto:ramon_w...@hotmail.com g t; To: rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org Date: Thu, 8 Dec 2011 11:59:21 +0800 Subject: [rules-users] Can Drools supply large Knowledge Base? Hi All I'm new to Drools, I will build a very large Knowledge Base, let's say it will be larger than 100GB, the files will be stored in a distribute database, so can Droools supply this large Knowledge Base? Any solution? Thank you very much. Cheers Ramon ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Tell me to RTFM
In order to invoke another RF file you use the Reusable Sub-Process. To select the process to invoke you specify a processId. This must match the processId defined for the process in the RF file. For this to work you obviously have to have loaded both RF files into the knowledge base. Hope that helps, Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of ronalbury Sent: 08 December 2011 17:22 To: rules-users@lists.jboss.org Subject: [rules-users] Tell me to RTFM I am sure this must be a case of RTFM, but please tell me which FM and if there is a section, in particular I should read. I am running JBoss Designer Studio 4.1.1.GA. It allows me to create RF files and comes with a number of Flow (or should I say jBPM) components, but not all of them. Do I need to download and install the full jBPM to get the rest of the components in eclipse? The feature I most want now is *embedded sub-process*. I have been trying to play with *reusable sub-process* to get a feel for sub-processes in general, but I'm stuck here too ... I'm sure this is another RTFM. I assume that when I am designing an RF I should be able to reference another RF to use as the sub-process as part of the graphical RF definition. The other jBPM components (e.g. RuleTask, Gateway, etc) have pretty self-explanatory properties ... but when I look at the reusable sub-process I see no way to indicate what RF I want to use for that sub-process. Thanks in advance -- View this message in context: http://drools.46999.n3.nabble.com/Tell-me- to-RTFM-tp3570837p3570837.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Tell me to RTFM
Its arbitrary but we tend to go for package.name. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of ronalbury Sent: 09 December 2011 14:44 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Tell me to RTFM Thanks, Thomas For some reason my mind went to 'PID' when I saw process id. Here's a follow-up. When I define an RF I set the Package, the Name and the Id. If I set the Package to com.a.b.c and I want the Name to be Foo, should I set the Id to be Foo, to be com.a.b.c.Foo, or is it entirely arbitrary (no best practice). Thanks again -- View this message in context: http://drools.46999.n3.nabble.com/Re-rules- users-Tell-me-to-RTFM-tp3572470p3573041.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] This (ordered) record validation approach is working
Is this presentation available anywhere? -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 08 December 2011 07:13 To: Rules Users List Subject: Re: [rules-users] This (ordered) record validation approach is working In my Rules Fest 2011 boot camp Rule-Based Programming Design Patterns I presented a generic solution using linked rule engines for this and similar problems. -W On 08/12/2011, ronalbury ronalb...@gmail.com wrote: I didn't get any feedback when I posted earlier today, so I went ahead and implemented what I thought would work ... and I figured I should share it here since it seems to be working pretty well. I created a Rule Flow as follows: A Rule-Flow-Group that validates the arrays. Unfortunately I sometimes get multiple related arrays of records instead of a single array of records. I confirm that records with mandatory values have arrays with at least one element, and confirm that the related arrays are of equal length. Errors are logged. A subsequent Rule-Flow-Group that manages inserts. The data actually comes to me as one data structure comprised of sub-records of various types, and I have DRL files for each record type. Some of the sub-records are optional, and since subsequent rules would erroneously flag empty sub-records as errors I have rules here which only allow optional records containing values to be inserted into the system. I am currently using for-loops in the THEN section of some rules to deal with the array problem and would like to know if there is a better way. No errors are generated here. A subsequent Rule-Flow-Group that validates data. The data is all sent to me as Strings, even though many of the values are numbers, dates, etc. This Rule-Flow group tests the various fields using regular expressions, and if a regular expression fails then the record is flagged as having an error. Optional fields are dealt with by the regular expression allowing a blank. Errors are logged. A Diverging Gateway that splits the data into two ... records without validation errors are allowed to progress to the value-checking Rule-Flow group ... those with errors have nothing more done to them. I realize that I could, for instance, let records with bogus numbers thru as long as my string-to-integer routine is robust, however I don't want to flag the same record multiple times (once by reg-ex and then again by the next Rule-Flow-Group). A subsequent Rule-Flow-Group that checks the values and ranges of the numbers, dates, etc, and does other types of validation (e.g. if fieldA has a value greater than 20 then fieldB must be set to XYZ). Errors are logged. This Rule-Flow approach currently seems to be solving all of my problems, and it allows me to keep the rules simple and well structured such that most of them are reusable in other parts of our system. I'm interested in getting feedback on this approach ... it seems to be working pretty well for me. It allows me to deal with ordering issues and many of the if/else issues, while keeping the rules simple enough for our non-technical analysts to review without needing a developer to sit next to them. I realize this is a pretty mundane application for a powerful rules system, but it seems like a good fit nonetheless. Thanks Ron -- View this message in context: http://drools.46999.n3.nabble.com/This-ordered-record-validation-appro ach-is-working-tp3568933p3568933.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Salience activation-group
Thanks for your quick response, but I am still confused. An activation-group assures that only one rule in the group will fire (an XOR group) Salience controls the order of evaluation No salience controls the order of the activations firing. There is no ordering of evaluating rules because rules aren't evaluated. Instead the rules clauses are transposed into a RETE graph which evaluates each clause as the necessary data is available. If two rules share a clause then they may share a node in the RETE graph. The regular expression test has the higher salience and will trigger if it is a bad number ... so why is the other rule even being tested? The RETE graph is evaluated as deeply as possible in order to produce the current list of possible activations. The activations are then sorted by salience and filtered by agenda-group. The top of the list is taken and fired. If any other pending activations have the same activation-group those pending activations are then removed. (It's a lot more complicated than that as you have things such as lock on active, no-loop, etc but it hopefully makes it make a little more sense. In the mean time I will re-write the underWritingClassAsInt method to deal with a bad number ... but this seems wrong to me. Or do the check for both parts in both rules , or use inheritance, but the easiest way would probably be to just have it return null if the number isn't valid - at least if you are just doing in comparisons. Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Salience activation-group
Good question, not sure it is documented properly at the moment, I think it is the extends keyword, but you can't easily use it anyway as you want the inverse of the other rule (regex doesn't match) rather than the regex does match. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Java Bean Sent: 06 December 2011 16:35 To: Rules Users List Subject: Re: [rules-users] Salience activation-group Or do the check for both parts in both rules , or use inheritance, but the easiest way would probably be to just have it return null if the number isn't valid - at least if you are just doing in comparisons. How do I use inheritance in Drools ? From: Swindells, Thomas tswinde...@nds.commailto:tswinde...@nds.com To: Rules Users List rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org Sent: Tuesday, December 6, 2011 11:15 AM Subject: Re: [rules-users] Salience activation-group Thanks for your quick response, but I am still confused. An activation-group assures that only one rule in the group will fire (an XOR group) Salience controls the order of evaluation No salience controls the order of the activations firing. There is no ordering of evaluating rules because rules aren't evaluated. Instead the rules clauses are transposed into a RETE graph which evaluates each clause as the necessary data is available. If two rules share a clause then they may share a node in the RETE graph. The regular expression test has the higher salience and will trigger if it is a bad number ... so why is the other rule even being tested? The RETE graph is evaluated as deeply as possible in order to produce the current list of possible activations. The activations are then sorted by salience and filtered by agenda-group. The top of the list is taken and fired. If any other pending activations have the same activation-group those pending activations are then removed. (It's a lot more complicated than that as you have things such as lock on active, no-loop, etc but it hopefully makes it make a little more sense. In the mean time I will re-write the underWritingClassAsInt method to deal with a bad number ... but this seems wrong to me. Or do the check for both parts in both rules , or use inheritance, but the easiest way would probably be to just have it return null if the number isn't valid - at least if you are just doing in comparisons. Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.commailto:postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.orgmailto: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] Memory leak in Drools InputMarshaller - JBRULES-3303
We've identified a memory leak in Drools when using JPAKnowledgeService.loadStatefulKnowledgeSession. We've raised the issue here https://issues.jboss.org/browse/JBRULES-3303?focusedCommentId=12647082#comment-12647082 The problem is that the InputMarshaller ends up registering a listener on the knowledge base twice, but only cleans up one of them when the session is disposed. This results in the KnowledgeBase keeping a reference to the session and leaking memory. I've done an analysis of it and the fix appears to be changing InputMarshaller line 204 from session.setKnowledgeRuntime(new StatefulKnowledgeSessionImpl(session)); to new StatefulKnowledgeSessionImpl(session); The sessionImpl calls session.setKnowledgeRuntime() during the constructor. I've attached a fuller explanation to the issue and there is sample code there as well. It would be great if this could be applied to the 5.3 branch as we need this fix in order to be able to deploy our application. Thanks, Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to define static constant variable
If you always have it as the first condition in your rule then Drools will only create a single node in the tree to do the match and the cost would be negligible. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Zhao Yi Sent: 22 November 2011 14:25 To: rules-users@lists.jboss.org Subject: Re: [rules-users] How to define static constant variable The more fact I insert, the more performance cost, If I have more than 100 rules, when I call insert, drools will check each rule condition to get all matched rules. This will be really time cost. -- View this message in context: http://drools.46999.n3.nabble.com/How-to- define-static-constant-variable-tp3527416p3527834.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] does drools support Class type parameter? myService(Class objectType)
you have to wrap it within an eval - we have to do this in a number of places. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of kapokfly Sent: 17 November 2011 13:15 To: rules-users@lists.jboss.org Subject: Re: [rules-users] does drools support Class type parameter? myService(Class objectType) our existing java implementation using reflection which requires Class. Are you saying invoking java code with a Class type parameter from DRL is not supported? - Ivan, your Panda, forever -- View this message in context: http://drools.46999.n3.nabble.com/does- drools-support-Class-type-parameter-myService-Class-objectType- tp3515507p3515712.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to use a temp variable accorss multiple rules?
It's up to you, wherever is most convenient. For primitives you would have to wrap it in an object though. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Zhao Yi Sent: 15 November 2011 14:21 To: rules-users@lists.jboss.org Subject: Re: [rules-users] How to use a temp variable accorss multiple rules? Where should I define the Output class, in Java code or drl file? How about if the Output is only a int or double value? Must I wrap the value into a Java class? -- View this message in context: http://drools.46999.n3.nabble.com/How-to- use-a-temp-variable-accorss-multiple-rules-tp3509713p3509799.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Using Drools with JSP application.
Drools is just a java library implementing some logic. The question you are asking is basically how do I write a JSP web application that uses some none JSP specific logic. It's not really any different to how you would write a JSP web app to read some records from a database, do some processing and then display the results on the UI. There are plenty of (none drools specific) tutorials on how to do this. The basic pattern is: You receive a request. You create a new stateless knowledge session (or a new stateful session, or even load an existing one depending on your requirements). You insert whatever data the requests says you should You run the rules. You extract the results You use process and return the results as necessary. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of sachintaware Sent: 14 November 2011 12:17 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Using Drools with JSP application. Hi Mike Waiting to hear from you.I am stuck a bit on these issue. Please point me to some example,for drools integrated with a simple jsp web-application(even standalone will do.). I want to display the result of rules on some UI(A web console,like Html- jsp).Is it possible?If yes,how?? Thanks and Regards Sachin -- View this message in context: http://drools.46999.n3.nabble.com/Using- Drools-with-JSP-application-tp3498955p3506664.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] ClassLoader parameter and Init function of RuleBaseConfiguration
No such method errors and the like when playing around with classloaders normally means that somewhere you have the same jar in the classpath with different versions, you may well then be loading the classes from different jars depending on which classloader you are using. Make sure that you definitely don't have any of the old 5.1 jars anywhere that could be being loaded by mistake. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of ssprick Sent: 11 November 2011 07:45 To: rules-users@lists.jboss.org Subject: Re: [rules-users] ClassLoader parameter and Init function of RuleBaseConfiguration *push* -- View this message in context: http://drools.46999.n3.nabble.com/ClassLoader-parameter-and-Init- function-of-RuleBaseConfiguration-tp3489741p3499019.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] jbpm 3.2.x verssion .....
It's java. As long as you have a compatible JVM then it should run. Have you encountered any problems using it? Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Sumeet Karawal Sent: 11 November 2011 09:12 To: rules-users@lists.jboss.org Subject: [rules-users] jbpm 3.2.x verssion . Hi, Can any body let me know whether jbpm v 3.2.8 is compatible with sun solaris. If not then which of the versions among v3.2.x is compatible with it. As I have to install it in both Windows and Sun Solaris. Thanks in advance, Sumeet Karawal Mailto: sumeet.kara...@tcs.com =-=-= 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 ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Security test cases for Drools
If you are allowing customers to define their own rules then you are effectively allowing them to execute any arbitrary java statements. You either need to have someone review and check all their rules before they are applied, restrict what they can do to the UI to such a level you are sure they can't compromise it (perhaps DSL might work?), sanatize there input to a whitelist of statements (probably no eval and very limited in what they can put in the then part, or you could go the whole hog and setup a java security sandbox and classloaders to place limits on what operations they can do - though even then you need to design it carefully so they can't modify any of your application state. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of kapokfly Sent: 09 November 2011 17:10 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Security test cases for Drools Thanks Edson. We are developing a web based UI (if possible embed guvnor into our application) and open the ability to customers to define their own rules, so a company policy on this won't work. Will evaluate other concern points and have more discussions on this. Ivan -- View this message in context: http://drools.46999.n3.nabble.com/Security- test-cases-for-Drools-tp3494072p3494170.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule Flow: Diverge/Converge Issue with one-to-many paths being exected
Can you split it into two separate diverges? Diverge to B first and always follow the other path which then does the A C, Similarly at the other end wait for A C and then a second wait to add in the condition for B. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of dcrissman Sent: 09 November 2011 15:05 To: rules-users@lists.jboss.org Subject: [rules-users] Rule Flow: Diverge/Converge Issue with one-to-many paths being exected Drools Version: 5.1 (We are looking into upgrading, but not an option at this time) I have need of a rule flow that will allow a diverge on one-to-many paths and then converge and continue on only once the paths that were executed have all finish. Say I have path A, B, C. The constraints on the diverge node indicate that A C should be executed simultaneously, but B should not. Then the converge node should wait for A and C to finish, but not care about B as it was not executed by the diverge. Initial attempt was to use Diverge(OR) and Converge(AND). The problem is that the Converge (I think) waits on B indefinitely and so the process exits out with no error message. It looks like n-of-m is kind of what I want, except I have no way to know how many paths the Diverge kicked off. Any thoughts on how this could be done? Much Appreciated! -- View this message in context: http://drools.46999.n3.nabble.com/Rule-Flow- Diverge-Converge-Issue-with-one-to-many-paths-being-exected- tp3493775p3493775.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Using Drools Flow with Multiple Fact Types
Yes, you can use or split nodes with appropriate conditions. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Jason Sent: 08 November 2011 13:33 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Using Drools Flow with Multiple Fact Types Can anyone help with this? It's been two weeks with no replies and my attempts to work around this problem are proving unsuccessful. Can a Drools flow handle multiple types of data being passed through it (e.g. ten different POJOs) such that one of the data types (User) is selectively directed down one of multiple paths based on a field value (User.Program) but the rest of the facts (Activities, Accounts, Connections) are sent down all paths? I'm looking to apply different sets of rules to different Users based on the program they're in. Any help will be most welcome!!! -- View this message in context: http://drools.46999.n3.nabble.com/Using- Drools-Flow-with-Multiple-Fact-Types-tp3449939p3490286.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] WorkingMemoryLogger + statelessSessions = memory leak?
Anybody? From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Swindells, Thomas Sent: 21 October 2011 14:49 To: Rules Users List (rules-users@lists.jboss.org) Subject: [rules-users] WorkingMemoryLogger + statelessSessions = memory leak? Hi everyone, I believe that there is a memory leak when using WorkingMemoryLoggers with statelessSessions. This was raised against 5.1.1 but I think it will still exist in the latest as well. Our code basically has the following pattern: KnowledgeBase kb ==; while(nextEvent()) { StatelessKnowledgeSession session = kb.newStatelessKnowledgeSession(); auditor = new WorkingMemoryInMemoryLogger(session); session.execute(getEvent()); dumpAuditLog(auditor); session = null; //no dispose it's stateless } We were getting Out of Memory Exception on site and the stack dump showed a high number of MemoryLoggers on the heap. Having a look at the code I think the problem is in the WorkingMemoryLogger constructor: } else if (session instanceof StatelessKnowledgeSessionImpl) { ((StatelessKnowledgeSessionImpl) session).workingMemoryEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).agendaEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).ruleFlowEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).getRuleBase().addEventListener( this ); } The last statement gets the knowledge base and attaches the event listener to it. As far as I can see there is no way to dispose of the WorkingMemoryLogger and you don't dispose stateless sessions (and it doesn't know about the listener anyway). This means that even after the session is gone the rule base still has a reference to the logger. The work around is to make the logger a singleton and clear it in each loop rather than creating a new one each time, however this obviously doesn't scale to multiple threads. Have I missed some fundamental in the api or should I raise a Jira for this? Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.commailto:postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] StatefulKnowledgeSession.dispose()
You only need to dispose of the session when you no longer want the session. It's perfectly valid to keep reusing the session as long as you want, inserting, removing and calling fire all rules as many times as you want. If you do reuse the session you just need to be careful that previous iterations of the loop don't have undesirable results on subsequent executions - eg if your rules insert control facts and you don't tidy them up. So in the code below you should just move the dispose outside the loop after you have done all the iterations. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of tonytang Sent: 21 October 2011 10:55 To: rules-users@lists.jboss.org Subject: Re: [rules-users] StatefulKnowledgeSession.dispose() B.T.W I use Drools 5.2 to test Hi, I have a quesion about StatefulKnowledgeSession.dispose(). Can continue to use the session instance ofter call dispose() method. I write a test code to test it and it is works fine. and it is almot 10 time fast than not call dispose(). Why??? But When I use Jboss Enterprise BRMS to run this test case. It is throw a NullPointException when call dispose() at the second time. Why for (int i = 0; i 100; i++) { FactHandle handle = session.insert(messageList.get(i));// session.fireAllRules(); session.retract(handle); session.dispose(); } ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] StatefulKnowledgeSession.dispose()
It's probably because dispose unregisters from various listeners and clears up some housekeeping resources, timers etc. It's possible your rules are simple enough that they don't need any of this and so not calling the listeners saves a significant amount of time - particularly if your test case is overly trivial . Whether it keeps working in any future versions I wouldn't want to guarantee you, dispose may start nulling out fields etc that would break future calls to the methods. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of tonytang Sent: 21 October 2011 11:29 To: rules-users@lists.jboss.org Subject: Re: [rules-users] StatefulKnowledgeSession.dispose() But how to explain if I call dispose() in the loop the performance improve 10 times? I already call the retract after every fireAllRules I know we should not call dispose when we still need to use it. ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] WorkingMemoryLogger + statelessSessions = memory leak?
Hi everyone, I believe that there is a memory leak when using WorkingMemoryLoggers with statelessSessions. This was raised against 5.1.1 but I think it will still exist in the latest as well. Our code basically has the following pattern: KnowledgeBase kb ==; while(nextEvent()) { StatelessKnowledgeSession session = kb.newStatelessKnowledgeSession(); auditor = new WorkingMemoryInMemoryLogger(session); session.execute(getEvent()); dumpAuditLog(auditor); session = null; //no dispose it's stateless } We were getting Out of Memory Exception on site and the stack dump showed a high number of MemoryLoggers on the heap. Having a look at the code I think the problem is in the WorkingMemoryLogger constructor: } else if (session instanceof StatelessKnowledgeSessionImpl) { ((StatelessKnowledgeSessionImpl) session).workingMemoryEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).agendaEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).ruleFlowEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).getRuleBase().addEventListener( this ); } The last statement gets the knowledge base and attaches the event listener to it. As far as I can see there is no way to dispose of the WorkingMemoryLogger and you don't dispose stateless sessions (and it doesn't know about the listener anyway). This means that even after the session is gone the rule base still has a reference to the logger. The work around is to make the logger a singleton and clear it in each loop rather than creating a new one each time, however this obviously doesn't scale to multiple threads. Have I missed some fundamental in the api or should I raise a Jira for this? Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Help! Activations firing out of salience order
That's a relief. Any news as to when final will be released? Thanks, Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli Sent: 19 October 2011 01:23 To: Rules Users List Subject: Re: [rules-users] Help! Activations firing out of salience order This was a duplicate of https://issues.jboss.org/browse/JBRULES-3111 that was fixed last week. It will be released in 5.3.0.final. Edson 2011/10/18 Swindells, Thomas tswinde...@nds.commailto:tswinde...@nds.com Ouch looks like we and anybody on 5.1.1 needs to desperately update then. Though I am rather concerned by this issue https://issues.jboss.org/browse/JBRULES-3211 Rules fires on incorrect condition - has this been looked at/is the issue correct as a rules engine which fires random rules when it shouldn't would be problematic! Thomas From: rules-users-boun...@lists.jboss.orgmailto:rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.orgmailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 18 October 2011 11:05 To: Rules Users List Subject: Re: [rules-users] Help! Activations firing out of salience order There used to be a subtle bug in the PriorityHeapQueue containing the activations. See https://issues.jboss.org/browse/JBRULES-3044 -W 2011/10/18 Swindells, Thomas tswinde...@nds.commailto:tswinde...@nds.com In our project we have been experiencing a large number of intermittent unit test failures when we are testing our rules (on drools 5.1.1). After a lot of debugging, examining our rules for logic errors, experimenting and generally scratching our head trying to work out what is wrong, we have noticed that sometimes (but very intermittently) activations are firing in the wrong order. In our rulebase we have two rules, Rule A salience 80 and Rule B salience 70. Whilst debugging we made Rule A and B are identical other than rule B having some additional constraints on the end. Dumping out the agenda events we have observed the following actions occurring: BEFORE_FIRED rule X CREATED_ACTIVATION Rule A CREATED_ACTIVATION Rule B AFTER_FIRED rule X ... (no references to either rule/activation) BEFORE_FIRED Rule B CANCELLED Rule A AFTER_FIRED Rule B How can Rule B be firing before Rule A when both activations exist? Does anybody know of any bugs in 5.1.1 that may be causing this? We have a branch of code on 5.3 and that also has had intermittent unit test failures, we've not had chance to examine whether this is the same pattern or just a different logic issue. Please help, Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.commailto:postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.orgmailto: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.comhttp://www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Help! Activations firing out of salience order
In our project we have been experiencing a large number of intermittent unit test failures when we are testing our rules (on drools 5.1.1). After a lot of debugging, examining our rules for logic errors, experimenting and generally scratching our head trying to work out what is wrong, we have noticed that sometimes (but very intermittently) activations are firing in the wrong order. In our rulebase we have two rules, Rule A salience 80 and Rule B salience 70. Whilst debugging we made Rule A and B are identical other than rule B having some additional constraints on the end. Dumping out the agenda events we have observed the following actions occurring: BEFORE_FIRED rule X CREATED_ACTIVATION Rule A CREATED_ACTIVATION Rule B AFTER_FIRED rule X ... (no references to either rule/activation) BEFORE_FIRED Rule B CANCELLED Rule A AFTER_FIRED Rule B How can Rule B be firing before Rule A when both activations exist? Does anybody know of any bugs in 5.1.1 that may be causing this? We have a branch of code on 5.3 and that also has had intermittent unit test failures, we've not had chance to examine whether this is the same pattern or just a different logic issue. Please help, Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Help! Activations firing out of salience order
Ouch looks like we and anybody on 5.1.1 needs to desperately update then. Though I am rather concerned by this issue https://issues.jboss.org/browse/JBRULES-3211 Rules fires on incorrect condition - has this been looked at/is the issue correct as a rules engine which fires random rules when it shouldn't would be problematic! Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 18 October 2011 11:05 To: Rules Users List Subject: Re: [rules-users] Help! Activations firing out of salience order There used to be a subtle bug in the PriorityHeapQueue containing the activations. See https://issues.jboss.org/browse/JBRULES-3044 -W 2011/10/18 Swindells, Thomas tswinde...@nds.commailto:tswinde...@nds.com In our project we have been experiencing a large number of intermittent unit test failures when we are testing our rules (on drools 5.1.1). After a lot of debugging, examining our rules for logic errors, experimenting and generally scratching our head trying to work out what is wrong, we have noticed that sometimes (but very intermittently) activations are firing in the wrong order. In our rulebase we have two rules, Rule A salience 80 and Rule B salience 70. Whilst debugging we made Rule A and B are identical other than rule B having some additional constraints on the end. Dumping out the agenda events we have observed the following actions occurring: BEFORE_FIRED rule X CREATED_ACTIVATION Rule A CREATED_ACTIVATION Rule B AFTER_FIRED rule X ... (no references to either rule/activation) BEFORE_FIRED Rule B CANCELLED Rule A AFTER_FIRED Rule B How can Rule B be firing before Rule A when both activations exist? Does anybody know of any bugs in 5.1.1 that may be causing this? We have a branch of code on 5.3 and that also has had intermittent unit test failures, we've not had chance to examine whether this is the same pattern or just a different logic issue. Please help, Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.commailto:postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.orgmailto: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] Regession in 5.3.0-CR1: .drl file ending in a single line comment w/o EOL not accepted
Do you want a new Jira issue raised for this? From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Swindells, Thomas Sent: 12 October 2011 11:09 To: Rules Users List (rules-users@lists.jboss.org) Subject: [rules-users] Regession in 5.3.0-CR1: .drl file ending in a single line comment w/o EOL not accepted While in the process of upgrading to the latest version of drools I've just been hit by a regression where .drl file ending in a single line comment w/o EOL not accepted (https://issues.jboss.org/browse/JBRULES-2041) This was fixed and works in 5.1.1 but appears to be broken again :( The original Jira appears to be an exactly the same as what I'm experiencing now. Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.commailto:postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Expected release date for 5.3.0.Final and 5.2.1.Final?
Any day now- a couple of days ago they said the end of this week. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of itchupe Sent: 14 October 2011 14:59 To: rules-users@lists.jboss.org Subject: [rules-users] Expected release date for 5.3.0.Final and 5.2.1.Final? Hello there I will check out the latest drools version in novembre or decembre... when is the next final release to expect approximately? should I see it here? https://issues.jboss.org/browse/JBRULES Cheers. itchupe 3 drools :) -- View this message in context: http://drools.46999.n3.nabble.com/Expected- release-date-for-5-3-0-Final-and-5-2-1-Final-tp3421763p3421763.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Regession in 5.3.0-CR1: .drl file ending in a single line comment w/o EOL not accepted
While in the process of upgrading to the latest version of drools I've just been hit by a regression where .drl file ending in a single line comment w/o EOL not accepted (https://issues.jboss.org/browse/JBRULES-2041) This was fixed and works in 5.1.1 but appears to be broken again :( The original Jira appears to be an exactly the same as what I'm experiencing now. Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] StatefulKnowledgeSession construction executes sequentially (no multithread)
The problem is your test isn't calling fire all rules. You are testing just the creation of the sessions, this is expected to be fast and low cost and requires some synchronization for safety*. The process that is expected to take a significant amount of time is the inserting of the facts, firing the rules and getting the results, this should run in parallel correctly - but your test isn't testing this. Can you make a realistic test case then feed back the results. Thomas *I don't know the code, and it is possible that it could benefit from using a more sophisticated read/write lock but that is only worth implementing if session creation really does take up a significant amount of time. -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Juan Carlos Fernández Sent: 11 October 2011 11:49 To: rules-users@lists.jboss.org Subject: Re: [rules-users] StatefulKnowledgeSession construction executes sequentially (no multithread) We create one StatefulKnowledgeSession for every client (if 20 clients at same time, 20 StatefulKnowledgeSession are created) because every client has different environment for rule evaluation. Facts for one client does not have to collide with facts of other clients so this is the reason why we create multiple sessions. Let me explain all this in greater detail. When a client executes a SOAP operation, one StatefulKnowledgeSession is created and associated to the transaction. Every log generated by the transaction is inserted as a Fact. When transaction finishes, we fire all rules for the current transaction knowledge session in order to correlate all transaction logs. This transaction logs do not have to collide with other transaction logs so every thread (transaction) has its own StatefulKnowledgeSession. Our app locks and begin to use only one CPU thread because of newStatefulKnowledgeSession(). Do you think entry-points would be the solution? Is there any other solution? One solution is to use StatefulKnowledgeSession pool who creates instances but we have to retract all facts when returning session to pool. Concurrent executions and throughput is a key feature of our SOAP application. Thank you very much -- View this message in context: http://drools.46999.n3.nabble.com/StatefulKnowledgeSession-construction- executes-sequentially-no-multithread-tp3412107p341.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rule limit
For an even less technical solution you could have a person with a big stick standing behind the users... I think what we are all wondering is why you want to limit the number of rules! Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 06 October 2011 08:14 To: Rules Users List Subject: Re: [rules-users] rule limit On 6 October 2011 01:09, Davide Sottara dso...@gmail.com wrote: As far as I know, the parser does not check the number of rules in a DRL Maybe you could do something like this: (i) use a KnowledgeBuilder to load the DRL resource; (ii) before you add the packages to the knowledgeBase, iterate over kBuilder.getKnowledgePackages() to find the package generated from your DRL; (iii) use getRules().size() on the package to check if the number of rules exceeds your desired threshold This would limit the number of rules per package and not per DRL file. Crude and not foolproof, but very cheap is a bash oneliner: LIMIT=10; PATH=some.drl; if [ $(grep '^\s*rule\' $PATH | wc -l) -gt $LIMIT ]; then echo more than $LIMIT rules in $PATH; fi -W D. -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-rule-limit-tp3394660p339 8277.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Compilation errors with 5.3.0.CR1
Why do you need the and in the rule? Have you tried rule enabled paramId: 1, id: 0 salience 50 when def0: EmParamDefinition(paramName == p2, listIndex == -1) EmParamValue(paramDefinitionId == def0, requiredValue == 1) $param : EmParamValue(id == 1, enabled == false) not ParentDisabled(id == 1) then $param.setEnabled(true); update($param); end Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Waclaw Borowiec Sent: 05 October 2011 10:55 To: rules-users@lists.jboss.org Subject: [rules-users] Compilation errors with 5.3.0.CR1 Hello I'm sending the message once again due to problems with code samples visibility in the previous one. I've got following rule: rule enabled paramId: 1, id: 0 salience 50 when (def0: EmParamDefinition(paramName == p2, listIndex == -1) and EmParamValue(paramDefinitionId == def0, requiredValue == 1)) $param : EmParamValue(id == 1, enabled == false) not ParentDisabled(id == 1) then $param.setEnabled(true); update($param); end It compiles fine under Drools 5.1.1, but after switching to 5.3.0.CR1 I get following exception: [Error: unexpected end of statement] [Near : {... def }] ^ [Line: 1, Column: 4] at org.mvel2.compiler.AbstractParser._captureBlock(AbstractParser.java:1470) at org.mvel2.compiler.AbstractParser.captureCodeBlock(AbstractParser.java:14 46) at org.mvel2.compiler.AbstractParser.nextToken(AbstractParser.java:421) at org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:1 28) at org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:62 ) at org.mvel2.MVEL.analysisCompile(MVEL.java:668) at org.mvel2.MVEL.analysisCompile(MVEL.java:672) at org.drools.rule.builder.PatternBuilder.setInputs(PatternBuilder.java:854) at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:595) at org.drools.rule.builder.PatternBuilder.processConstraintsAndBinds(PatternB uilder.java:397) at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:309) at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:132) at org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.jav a:65) at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:80) at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2241) at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:802) at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java :388) at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder .java:566) at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.ja va:35) at com.proximetry.elmgr.services.DependenciesBean$Expander.addDrl(Depen denciesBean.java:110) It is (def0: EmParamDefinition(paramName == p2, listIndex == -1) and EmParamValue(paramDefinitionId == def0, requiredValue == 1)) line that causes the problem - the exeption disappears after removing it. What's interesting, when I add '$' sign to binding variable name, and the line looks like: ($def0: EmParamDefinition(paramName == p2, listIndex == -1) and EmParamValue(paramDefinitionId == $def0, requiredValue == 1)) instead of the exception I get DRL error: [DialectError message='Unable to wire compiled classes, probably related to compilation failures:sun.reflect.generics.reflectiveObjects.WildcardTypeImpl cannot be cast to java.lang.Class'] For completness, this is how I add DRL resources: public void addDrl(Reader rdr) { KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kBuilder.add( ResourceFactory.newReaderResource(rdr), ResourceType.DRL); if( kBuilder.hasErrors() ){ for( KnowledgeBuilderError err: kBuilder.getErrors() ){ StackTrace.error(this, err); } throw new IllegalStateException( DRL errors ); } knowledgeBase.addKnowledgePackages( kBuilder.getKnowledgePackages() ); } I would be grateful if someone has an idea, why after switching Drools version such problem exists. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes.
Re: [rules-users] Using object.getter in Decision table
Why are you using an extra data object -its far easier if your facts are actually facts in the working memory. What you have written as your rules is totally incorrect - you seem to be trying to write java method calls not rule statements. My advice is to a) try writing the same rule as a drl first before trying to represent it in a spreadsheet b) look at the intermediate drl that the spreadsheet compiler produces to get a better understanding of the output that the spreadsheet produces. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of jilani Sent: 04 October 2011 07:43 To: rules-users@lists.jboss.org Subject: [rules-users] Using object.getter in Decision table Hi, I have a scenario, where for decision table I will inject one object which holds all facts. Using those facts the decision table has rules. How to retrieve the child fact from parent in decision table. sample for this is as follows Java Code snippet: DataObject dataObj = new DataObject(); Fact1 fact1 = new Fact1(); Fact2 fact2 = new Fact2(); dataObj.setFact1(fact1); dataObj.setFact2(fact2); statelessKnowledgeSession.execute(dataObj); In decision table: --- CONDITION fact1 : DataObject().getFact1(); fact1.getData1().equalsIgnoreCase($param) Hello Here I am getting error. Please suggest me how to access the child fact from parent fact in decision table. -- View this message in context: http://drools.46999.n3.nabble.com/Using- object-getter-in-Decision-table-tp3392337p3392337.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] 5.3.0 CR1 has broken existing rules/flows
That looks really useful, I didn't know that you could do that! Any chance you could submit it as a patch to get the default version enhanced to do that! Thanks, Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 04 October 2011 08:42 To: Rules Users List Subject: Re: [rules-users] 5.3.0 CR1 has broken existing rules/flows I have found that any serious Drools application should write and deploy a consequence exception handler of its own. Perhaps you look at my modest efforthttp://members.inode.at/w.laun/drools/CustomConsequenceExceptionHandlingHowTo.html - I think it is still compatible. Any feedback welcome ;-) -W On 4 October 2011 04:46, lhorton lhor...@abclegal.commailto:lhor...@abclegal.com wrote: This is very good info. I have found those Drools ConsequenceExceptions a real PITA to troubleshoot. I wonder if the exception could be enhanced to show this info so users don't have to debug it? I mean, to have the exception message show the true culprit rule name, or something useful like that? -- View this message in context: http://drools.46999.n3.nabble.com/5-3-0-CR1-has-broken-existing-rules-flows-tp3390922p3392014.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Is it possible to retrieve the collection of Conditions from DecisionTable?
Looking at the SpreadsheetCompiler class you can do something like the following /** * Generates DRL from the input stream containing the spreadsheet. * * @param xlsStream *The stream to the spreadsheet. Uses the first worksheet found *for the decision tables, ignores others. * @param type *The type of the file - InputType.CSV or InputType.XLS * @param listener * * @return DRL xml, ready for use in drools. */ public String compile(final InputStream xlsStream, final InputType type, final RuleSheetListener listener) { final DecisionTableParser parser = type.createParser( listener ); parser.parseFile( xlsStream ); final Package rulePackage = listener.getRuleSet(); ListRule rules = rulePackage.getRules for(Rule r : rules) { r.getName(); ListCondition conditions = r.getConditions(); For(Condition c : conditions) { String snippet = r.getSnippet(); } } final DRLOutput out = new DRLOutput(); rulePackage.renderDRL( out ); return out.getDRL(); } Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 04 October 2011 08:53 To: Rules Users List Subject: Re: [rules-users] Is it possible to retrieve the collection of Conditions from DecisionTable? Since Toni confirms me even before I post this on the list: Using the Verifier way to get at a column from some spreadsheet is not for the faint at heart. In addition to what Toni wrote: source code in the Drools AST corner isn't even commented. -W 2011/10/4 Toni Rikkola toni.rikk...@gmail.commailto:toni.rikk...@gmail.com If you take a look at the Verifier it goes through the Drools AST with a visitor pattern. It starts by using getting the PackageDescr using DrlParser, this uses Drools internals so be warned that it might change in the future. Reader drlReader = new InputStreamReader( stream ); PackageDescr descr = new DrlParser().parse( drlReader ); After that it goes through the PackageDescr using PackageDescrVisitor. RuleDescrVisitor shows how to get the condition part from each rule. https://github.com/droolsjbpm/drools/blob/master/drools-verifier/src/main/java/org/drools/verifier/visitor/PackageDescrVisitor.java https://github.com/droolsjbpm/drools/blob/master/drools-verifier/src/main/java/org/drools/verifier/visitor/RuleDescrVisitor.java Toni On Oct 3, 2011, at 8:11 PM, Mark Proctor wrote: On 03/10/2011 18:03, Wolfgang Laun wrote: A condition does not have a name, as you write; values of the cells below a condition are (usually) literals. There is no API for extracting parts of a spreadsheet. You can look at the Drools source code (in the packages org.drools.decisiontable and .../parser) and write whatever you need - it is not too difficult. You can also look at drools-verifier, as that shows ho to analyse resulting rule fragments. Mark -W On 3 October 2011 17:05, RaviCKotaravi.k...@wellsfargo.commailto:ravi.k...@wellsfargo.com wrote: Hi All, for suppose I have a DecisionTable like below CONDITION ACTION - COND1 ACTION1 COND2 ACTION2 COND3 ACTION3 - This is just a representation of the DecisionTable. So I need to retrieve all the conditions and store them into a Collection like Set. Does Drools provide any such feature. We load the drools as below PackageBuilder builder = new PackageBuilder(); builder.addPackageFromDrl(new StringReader(drl)); //drl is the filepath of decisiontable excel // add the package to a rulebase (deploy the rule package). RuleBase ruleBase = RuleBaseFactory.newRuleBase(); ruleBase.addPackage(builder.getPackage()); I tried to look into api of RuleBase, tried to get the packages, Rules, Consequence, etc etc, but could not find any method, that gets me the condition name. When I tried to do Package[] packages = rulebase.getPackages(); for(Package pack : packages){ System.out.println(Package Name is : +pack.getName()); Rule[] rules = pack.getRules(); for(Rule rule : rules){ System.out.println(Rule name is : +rule.getName()); All I get is some representation of each row, but I'm specifically looking for the value of the first column (CONDITION) for each rule. Please offer some guidance here. -- View this message in context: http://drools.46999.n3.nabble.com/Is-it-possible-to-retrieve-the-collection-of-Conditions-from-DecisionTable-tp3390026p3390026.html Sent from the Drools: User forum mailing list archive at Nabble.comhttp://Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list
Re: [rules-users] Using object.getter in Decision table
The best place to start is the drools documentation http://www.jboss.org/drools/documentation particularly the expert guide. This shows both drl and spreadsheet syntax and examples. You are getting the exception because the first line of the condition should just be an object restriction eg fact1 : DataObject() Your second line is then a restriction on that data object. What you send from your screen and what you insert into the working memory doesn't have to be identical. Your screen may use a single object to relay the object but that doesn't mean you can't explode it into separate facts as you insert it into your working memory, but it depends on what you are trying to achieve - are these just validation rules or are you going to be modifying the objects? Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of jilani Sent: 04 October 2011 09:43 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Using object.getter in Decision table Thank You for your reply. I am trying to access all the facts through one fact, actually the scenario is we have multiple screens in our application and each screen will have multiple fields where we want to show/hide the screen/field based on data provided in screens. So Instead of sending each screen data separate, We thought of sending the parent object and inside the rules(i.e decision table) we want to access the data of specific screen. As mentioned by you, I am using the intermediate DRL output using below code SpreadsheetCompiler sc = new SpreadsheetCompiler(); String drlstr = null; try { drlstr = sc.compile(ResourceFactory.newClassPathResource(decisionTableSheet, this.getClass()).getInputStream(), InputType.XLS); } Here it is giving the rule parse exception and returning the package as null. Coming to DRL, I am facing difficulty in defining rules like scenarios as below - null check - need to use java String methods like equals() and length() - setting data in HashMap, ArrayList Actually I tried the above using a rule definition in Guvnor. It would be helpful If you can provide me the URL or some information to write rules using DRL. My Development environment: Drools 5.2 Eclipse with JBoss tools ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Getting Exception while running rules continuously on the Event Streams from Mule Component.
It may be worth you trying a later version of drools to see whether the issue still exists - there have been quite a few bug fixes since then! In theory it shouldn't be too much work to change - check the release notes for maven group/project id changes, but there are some subtle differences in some of the rule syntax validation in places which may or may not make it painful. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Hari Kishan Sent: 27 September 2011 13:33 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Getting Exception while running rules continuously on the Event Streams from Mule Component. *Drools Version : 5.0.1 * *The Drools API used in Mule *: drools-api-5.0.1.jar drools-compiler-5.0.1.jar drools-core-5.0.1.jar -- View this message in context: http://drools.46999.n3.nabble.com/Getting- Exception-while-running-rules-continuously-on-the-Event-Streams-from- Mule-Component-tp3372189p3372442.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Partial Unification / Derivation of Facts?
It's almost as if I need to specify a partial derivation or partial unification of the Fact type, which is only asserted once a rule indicates that it is providing the unbound portion of the derivation. I understand queries can be used for some sort of partial unification, but I have no clue how to apply them to my problem and I can't find any good examples or documentation on their usage/behavior. I don't fully understand what you are trying to achieve, but I think what you are asking for is the Trait support that has just been introduced in the latest release? Have a look at the latest release notes and see if that helps you. Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
This isn't an if statement evaluated left to right with an between each part. Drools uses the rete algorithm to make execution more efficient. Put very simply (and probably inaccurately) Rete creates an evaluation tree where inputs are put in the top and activations come out the end. In this case the tree would have: One node that evaluated condition1, this node outputs a list of all the facts that matches it. A node for condition 2 which outputs a list all the facts that match that condition. A node for the rule, this takes the outputs of the other two nodes and produces an activation for each pair of items (assuming condition 1 and 2 aren't related). If you had another rule with condition1 and condition3 then they would both share the first node greatly improving efficiency and re-evaluation time. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Saurabh Pandey Sent: 26 September 2011 08:15 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially take a simple scenario: when condition1 condition2 then ... Does the condition2 gets executed even if the condition1 is false, normally it should not because the conditions in the when are actually combined with an AND. Has anywhen tried this?? -- View this message in context: http://drools.46999.n3.nabble.com/Drools-all- lhs-execute-before-all-the-rhs-i-want-to-run-sequentially- tp3368215p3368464.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
You missed the second part of the instructions - once a rule has matched you need to make sure the other rules don't match. This can be achieved in multiple ways: Call the engines halt method - just stop evaluation. Retract the facts - then nothing else can match it. Update the facts to stop the condition from being matched - eg add a processed field and make the rules match only if processed is false. Insert a new fact and modify your rules to only run if that fact doesn't exist - eg add not YourResultObject() to the when's and insert(new YourResultObject()); to the thens. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Saurabh Pandey Sent: 26 September 2011 07:49 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially @Nguy I tried salience but it just orders the execution of when part, but still all when execute before the then parts -- View this message in context: http://drools.46999.n3.nabble.com/Drools-all- lhs-execute-before-all-the-rhs-i-want-to-run-sequentially- tp3368215p3368415.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
Have you read the expert guide? http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html_single/index.html - At least up to the end of chapter 4. Why are you using static fields and methods? You are changing the value of objects in the when condition which is really really really bad and it's no wonder nothing is working like you are expecting. The fact that you are using eval's is a good indication that your code is written wrong, for simple rules you never need to use it. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Saurabh Pandey Sent: 26 September 2011 11:22 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially these are my rules: rule Rule 03 salience 10 when $info : RuleRunner() eval(RuleRunner.check()) eval(RuleRunner.setIt()) then System.out.println(3**); $info.printResult(1); end rule Rule 04 salience 8 when $info : RuleRunner() eval(RuleRunner.check()) then System.out.println(4**); $info.printResult(2); end these are my java methods: static boolean cvar = true; public void printResult(int i){ System.out.println(i); } public static boolean check(){ System.out.println(check**); return cvar; } public static boolean setIt(){ cvar = false; return true; } this is how i am invoking the rules: KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newFileResource(rule03.drl), ResourceType.DRL ); if ( kbuilder.hasErrors() ) { System.err.println( kbuilder.getErrors().toString() ); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() ); StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(); ksession.execute(new RuleRunner()); This is the output: check** 3** 1 4** 2 Why is check printing only once though its called 2 times in 2 rules, and when cvar is false then also 2nd rule's then part is executing? Is it that static methods of same name are called once and there result is stored and used in all rules?? -- View this message in context: http://drools.46999.n3.nabble.com/Drools-all- lhs-execute-before-all-the-rhs-i-want-to-run-sequentially- tp3368215p3368864.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially
As I said, try reading the expert doc, there's some examples in there which you can base your code on. Once you've done that or if you have any questions about the samples/what the documentation means then post them and we'd be pleased to help, but the first step is to structure your code correctly using objects that follow the bean conventions and rules structured correctly with conditions against objects and appropriate modify statements. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Saurabh Pandey Sent: 26 September 2011 11:51 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Drools all lhs execute before all the rhs, i want to run sequentially @thomas thanks for your comments I am new to drools, can u plz give me an alternative to the above code. -- View this message in context: http://drools.46999.n3.nabble.com/Drools-all- lhs-execute-before-all-the-rhs-i-want-to-run-sequentially- tp3368215p3368917.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Regression with Drools 5.3.0-CR1
I've just tried upgrading from Drools 5.3.0-CR1 from the beta and I've hit a regression. JBoss seems to have been down for most of today so I haven't been able to raise a Jira for it. In our model we have Facts which contain fields of java.lang.class, we then have a rule which checks that they aren't null. Eg Fact { ClassObject classField} Rule xyz When Fact(classField != null) Then ... End This is giving the following exception Caused by: java.lang.ClassCastException: org.drools.base.field.ObjectFieldImpl cannot be cast to org.drools.base.field.ClassFieldImpl at org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772) at org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87) at org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109) at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130) at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369) at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134) at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451) at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379) at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204) at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244) at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330) at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291) at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882) at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180) ... 149 more Wrapping the classField != null within an eval appears to be a work around. This is in the suspect method: public boolean evaluate(InternalWorkingMemory workingMemory, final InternalReadAccessor extractor, final Object object1, final FieldValue object2) { Object value1 = extractor.getValue( workingMemory, object1 ); Object value2 = object2.getValue(); if ( value2 == null ) { ClassFieldImpl classField = (ClassFieldImpl) object2; value2 = classField.resolve( workingMemory ); } return comparator.equals( value1, value2 ); } I think the if statement just needs an instanceof check as well or some other way to track the fact that null may be a valid value to be comparing with! Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Issue using global 'variable' with Drools 5.2 in DRL
If it a java.util.Date then drools supports comparing them out of the box so you can just do subObjcet.dateField = now. Just make sure you don't mix up instances of java.util.Date and java.sql.Timestamp (eg if you have jpa code fetching object from the db) as sun in their wisdom made it that you can't compare them with each other! Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Slorg1 Sent: 23 September 2011 13:54 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Issue using global 'variable' with Drools 5.2 in DRL Hi Wolfgang, Thank you for answering, here is the rule rewritten but closer to reality: // package // imports global java.util.Date now; rule MyRule salience 5 when // Prevent rule activation for other offer types. MyObject(type == Type.TYPE_SOUGHT) $candidate : Candidate( subObject.dateField != null subObject.dateField.time = now.time) then // do something end A value for 'now' being set like so: session.setGlobal(now, new Date()); // Date being the java.util.Date. But I do not think that matters because 'compilation' fails at this point. Thank you in advance for your time. -- View this message in context: http://drools.46999.n3.nabble.com/Issue- using-global-variable-with-Drools-5-2-in-DRL-tp3360343p3361770.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Log4j in the rules?
Just add the logger in as a global and call it from the when part. -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of nick_fun7921 Sent: 15 September 2011 18:09 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Log4j in the rules? Hi, I know its quite an old thread, but just wanted to check if you can post some code snippet of how to use the log4j in DRL file. Thanks, Nick -- View this message in context: http://drools.46999.n3.nabble.com/Log4j-in- the-rules-tp54853p3339574.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Log4j in the rules?
Then part not when part .. really must wake up before posting -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Swindells, Thomas Sent: 16 September 2011 09:07 To: Rules Users List Subject: Re: [rules-users] Log4j in the rules? Just add the logger in as a global and call it from the when part. -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of nick_fun7921 Sent: 15 September 2011 18:09 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Log4j in the rules? Hi, I know its quite an old thread, but just wanted to check if you can post some code snippet of how to use the log4j in DRL file. Thanks, Nick -- View this message in context: http://drools.46999.n3.nabble.com/Log4j-in- the-rules-tp54853p3339574.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] (no subject)
To do that shouldn't you just be doing something like the following? You should be using the knowledge* apis rather than the old rules* apis. KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newReaderResource(new File(fileReader)), ResourceType.BRL); KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(conf);knowledgeBase.addKnowledgePackages(kbuilder.getKnowledgePackages()); knowledgebase.newStatefulSession(); Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of AZZAZ mohamed Sent: 16 September 2011 10:12 To: Rules Users List Subject: Re: [rules-users] (no subject) I use version drools-core5.2.0 and drools-compiler 5.2.0 In fact I created my business rules with the guided rule . it generates automatically a. Brl. I want to convert it to .drl me to build my package builder. Paris ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Memory leak in 5.2/5.3
This probably isn't very optimal but it should work: CollectionFactHandle factHandles = session.getFactHandles(); for(FactHandle f : factHandles) { session.retract(f); } Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of vadlam Sent: 14 September 2011 02:39 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Memory leak in 5.2/5.3 we are seeing similar memory leak with 5.2.0.Cr1 version of drools. are there any other alternatives such as using a different version of jbpm jar if that is the cause of the problem? we are currently using the jbpm-flow-5.1.0.Cr1.jar. If not, is there a method that removes all the facts from the ksession so that it can be reused? for ex, the existing code (simplified) is as follows: ksession = knowledgeBase.newStatefulKnowledgeSession(); for (Object obj : objList) { ksession.insert(obj); } ksession.startProcess(ruleFlowProcessName); ksession.fireAllRules(); do some response processing here ksession.dispose(); Thomas, Can you please elaborate on what you did to clean out the facts from the memory ? -- View this message in context: http://drools.46999.n3.nabble.com/rules- users-Memory-leak-in-5-2-5-3-tp3280351p3334543.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Spreadsheet: Rule Compilation error (xxx) cannot be resolved: Keeping running total
If you dump out the xml it converts the spreadsheet to you can see what the resulting DRL is. Mantis is right in what the output is – if you don’t merge the condition column you’ll get a drl as below (If there exists a Condition (c1) such that its payment $param(1) AND there exists a Condition (c2) such that its payment = $param(2). If you merge the condition column the constraints apply to the same Condition object with the comma being the implicit and (if there exists a Condition c1 such that its payment $param(1) AND its payment = $param(2). Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of john@oa Sent: 09 September 2011 16:28 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Spreadsheet: Rule Compilation error (xxx) cannot be resolved: Keeping running total Thanks Manstis Actually I found that the issue was caused by me having incorrectly placed the RuleTable statement in the spreadsheet, I believe the CONDITION's in the columns are by default: AND joined. On Fri, Sep 9, 2011 at 3:57 PM, manstis [via Drools] [hidden email]/user/SendEmail.jtp?type=nodenode=3323194i=0 wrote: Does your Condition span the two columns with the payment $param? e.g. | Condition | |-+--| |payment $param | payment = $param| |-+--| Otherwise you are creating rules that check the following:- when Condition(payment ) then ... when Condition(payment 1000) then ... Whereas you really require:- when Condition(payment 0, payment = 1000) then ... etc 2011/9/9 john@oa [hidden email]http://user/SendEmail.jtp?type=nodenode=3323110i=0 Thanks Iaune That is really helpful. Yes, I need the ranges to be mutually exclusive, what is the easiest way to do that? Feel a bit cheeky asking another question, but you seem to know what you are talking about! I have tried adding two conditions to enforce the range, but that doesn't seem to work - see below. I still get multiple rules firing. Also can you recommend any good resources for learning all of this, apart from the online documentation? Would you know if any of the Drools books are any good? payment $param payment = $param Payment Greater Than Payment Less Than or Equal To 0 0 1500 1500 2000 2000 3000 3000 4000 On Fri, Sep 9, 2011 at 2:22 PM, laune [via Drools] [hidden email]http://user/SendEmail.jtp?type=nodenode=3323074i=0 wrote: The error you get is due to the second condition (application: Application()) not being included in the generated rules. Empty cell means: the column's snippet is not included in the rule. Since you don't have a constraint for Application() you can employ a trick: remove the column and prefix the text application: Application() to the text in cell C7. In Rule 1, do you really want to test whether a payment is not greater than zero? Do you realize that Rules 2 and 3 would both fire for certain payment amounts? You can update a String field. To concatenate, use x.setString( x.getString() + whatever ); -W On 9 September 2011 14:08, john@oa [hidden email]http://user/SendEmail.jtp?type=nodenode=3322896i=0 wrote: Guvnor: guvnor-5.2.0.Final-tomcat-6.0 Hi I am a Drools Newbie and I have an integer field called score that I need to add to when a rule matches in a spreadsheet decision table. i.e. the score field should hold a running total of all scores that are matched. However, I can't even update the field in the table. I have attached the spreadsheet for review. In this spreadsheet I am simply trying to set the score, and that is failing with: DScoringTable] Rule Compilation error application cannot be resolved My goal is to have different decision tables that will all need to update the same score, and keep a running total of the total score. Any help very much appreciated! I hope that I am just missing something obvious. http://drools.46999.n3.nabble.com/file/n3322713/demo-score-sheet.xls demo-score-sheet.xlshttp://drools.46999.n3.nabble.com/file/n3322713/demo-score-sheet.xls%0Ademo-score-sheet.xls In future I may wish to also update a String field and keep concatenating to that field, is this possible? John -- View this message in context: http://drools.46999.n3.nabble.com/Spreadsheet-Rule-Compilation-error-xxx-cannot-be-resolved-Keeping-running-total-tp3322713p3322713.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list [hidden email]http://user/SendEmail.jtp?type=nodenode=3322896i=1 https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list [hidden email]http://user/SendEmail.jtp?type=nodenode=3322896i=2 https://lists.jboss.org/mailman/listinfo/rules-users If you reply to this email, your message will be added to the discussion
Re: [rules-users] Decision table empty action cell
There's no easy option. One solution is to merge the cell across from your condition column - if someone duplicates a row they'll still have the value merged and it looks nicer than having a column of N/A The other approach I tend to use is just to set the column heading to be must be N/A rather than retract the person. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Bruno Freudensprung Sent: 07 September 2011 12:19 To: Rules Users List Subject: [rules-users] Decision table empty action cell Hi, I am implementing a decision table that looks like: CONDITION ACTION $p : Person name == $1 retract($p); Person name Retract the person Fred N/A Kenny N/A The problem is generated rules have an empty RHS unless I put a string (here N/A) on each line of the Action column, and I'd like to hide this column in my final spreadsheet. Does anyone know a way to instruct Drools to generate the LHS even if the cell is empty? If it is not possible, do you know any Excel trick to automatically fill the Action cell with an arbitrary value (here N/A) when a new line is inserted in my table? Many thanks in advance for your help, Best regards, Bruno. ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] encounter NullPointerException when adding ruleflow
Are you sure that basicFlow.rf is in your classpath correctly? From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of James Yu Sent: 06 September 2011 10:08 To: rules-users@lists.jboss.org Subject: [rules-users] encounter NullPointerException when adding ruleflow Hi all, I tried to run Drools in a webapp, it runs smoothly when I only load simple rules. The spec I have: AP server -- WASCE2.1 (or geronimo 2.1) Spring -- 3.0.5 Drools -- 5.2 Fianl JVM -- IBM SDK 1.6 When I tried to use ruleflow -- execute drl in rf, I got NullPointerException with the following trace: exception org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549) javax.servlet.http.HttpServlet.service(HttpServlet.java:693) javax.servlet.http.HttpServlet.service(HttpServlet.java:806) root cause java.lang.NullPointerException org.drools.compiler.PackageBuilder.addProcessFromXml(PackageBuilder.java:516) org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:556) org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28) net.viralpatel.drools.core.DroolsCore.createKnowledgeBase(DroolsCore.java:17) net.viralpatel.contact.controller.ContactController.listContacts(ContactController.java:41) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:59) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:39) java.lang.reflect.Method.invoke(Method.java:612) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549) javax.servlet.http.HttpServlet.service(HttpServlet.java:693) javax.servlet.http.HttpServlet.service(HttpServlet.java:806) net.viralpatel.drools.core.DroolsCore.createKnowledgeBase(DroolsCore.java:17) is the following line: builder.add(ResourceFactory.newClassPathResource(basicFlow.rf), ResourceType.DRF); Any advise is appreciated. This is a UTF-8 formatted mail --- James C.-C.Yu ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Trapping runaway rules
I've found no-loop to be pretty much completely useless. It only stops the rule from triggering itself, but it doesn't stop loops where multiple rules constantly trigger each other. Eg when they both depend on and modify the same fact. Individually with no-loop they would both work fine, but combined together you get into a loop. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of rou...@mm.di.uoa.gr Sent: 30 August 2011 19:15 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Trapping runaway rules I would also suggest that you add a no-loop directive to each one of your rules, at least to the ones written by the end-users (if I understood correctly). As I have (painfully) found, it is extremely easy to produce never-ending loops on (end)user-created rules. -Stathis Dean Whisnant wrote: Wolfgang, Thanks for the thoughts and suggestions. My current implementation does have a limited number of rules we would expect to fire, with little chance of multiple firings. I understand the beauty of the way the engine re-evaluates and re-fires if needed (oversimplification). After posing the question here I dug into the javadocs and saw that fireallrules accepts and int for the max activations and returns an int of the number of activations. I feel pretty comfortable using this method and comparing the in and out ints to be able to do some exception handling (email notifications of issues). If anyone else has other possible solutions/formulas they would use to determine a rule is running away I'd be interested in hearing your ideas. I agree, the person with a bit of savvy would detect the errors themselves, but the nature of my application is that the firing is cloud based and somewhat invisible to the rule creators. What I hope to be able to do with halting the process and informing them of runaways is that they can then review their log of rules fired for each transaction and either resolve the rule issue themselves or contact others who can assist them. The one we had last week had created a 6 Gb rules fired log before anyone was suspicious that there was an issue. :O Again, thank you for the wonderful feedback! Dean From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: Tuesday, August 30, 2011 11:20 AM To: Rules Users List Subject: Re: [rules-users] Trapping runaway rules On 30 August 2011 14:27, Dean Whisnant d...@basys.commailto:d...@basys.com wrote: My project involves rule creation by customers, business analysts, and developers. We have a base set of rules that fire for every transaction and then we fire custom rules within a stateful session. An issue I've started to run into is rules being created that fire endlessly. I initialize the session with an event listener that we use to extract all rules fired for each line item of a transaction. Once the session is initialized and all rules from various agenda groups loaded we do a fireall rules. My questions are: 1) how can I detect I have a runaway rule/rules. Is there a method or listener that could detect this for me? Does anyone have a formula they use to do so? I had thought that I could use my event listener that I track the rules with to grab the last X number of rules fires and see if rule y gets fired more that z times. But is there a simpler method? It's not even as simple as that. ;-) Multiple firing of a rule r within n firings may not be loops if this happens with different facts bound to patterns. 2) once I've detected a runaway rule, how can I gracefully stop drools rule execution? I read of the command drools.halt in different posts, but not sure if this would be what I'm looking at doing. If you detect it during a consequence execution, throw an exception and catch it with a custom consequence exception handler. Using a limit on fire all rules might be another way, in combination with logging all activations. Finally, someone with a little savvy should be able to detect some just by looking at them. The telltale marks are well known... -W Any thoughts are appreciated. Thank you! Dean StatefulKnowledgeSession ksession = buildOutgoingStatefulKnowledgeSession(supportingUDTList); // AgendaEventListener agendaListener = new HipaaAgendaListener(); ksession.addEventListener(_ruleLog); for (int i = 0; i _agendaGroups.size(); i++) { if (_log.isDebugEnabled()) _log.debug(Focus on Agenda Group + _agendaGroups.get(i)); ksession.getAgenda().getAgendaGroup(_agendaGroups.get(i)).setFocus(); // Fire them all try {
Re: [rules-users] Rule one-by-one comparison
Wouldn't it be easier to analyze the pre-converted xml document rather than trying to do it on the compiled knowledge base (presumably you keep the old xml file around) - this way it is just string and xml manipulation, though it depends on how exactly the matches must be. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of miguel machado Sent: 26 August 2011 15:55 To: Rules Users List Subject: Re: [rules-users] Rule one-by-one comparison Hi there, Thanks for replying. I will try to explain my current challenge a bit further: I have a ruleset which is sent by an external application in XML format. I load it to a new knowledge package and then into a knowlegde base. It is made of smaller subsets of 3 rules each (a set rule, a reset rule and a clear rule) that control my application's internal logic, which must be stateful and kept on disk (basically, there are 2 important hashmaps). Whenever the rules change, a new XML ruleset is sent and my application restarts and loads the new file the exact same way. However, I need to resume the application state (as it was before the restart). I also have to do this selectively, because I only care about the application state on a per-rule basis: - If a rule keeps the same LHS, I need to resume the application state before restart regarding that rule; - If a rule has been modified, I may discard the state regarding that rule (do not need to load it); I don't think I can refactor this problem into smaller ones, the application internal logic is indeed complex I'm afraid. The rules are analyzed in a stateless way BUT they control a set of critical information which must be stateful (beyond restarts). There is a (not-so-direct) correspondence between each (fire, reset, clear) rule subset and the information that keeps track of the internal state, so that's why I need to verify rule-by-rule what has changed between restarts. I hope this helps to describe the problem. Thanks again for reading. Any help is greatly appreciated. _ miguel, PT 2011/8/26 Swindells, Thomas tswinde...@nds.commailto:tswinde...@nds.com Can you share what you actual requirement is and why you need to do it? Can you perhaps change the problem into one that is simpler to solve? Ie rather than comparing knowledge bases can you get the input to these knowledgebases? Can you control what that input is, if it is a DSL or a spreadsheet then your comparision job will probably become a lot simpler. Thomas From: rules-users-boun...@lists.jboss.orgmailto:rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.orgmailto:rules-users-boun...@lists.jboss.org] On Behalf Of miguel machado Sent: 26 August 2011 13:01 To: Rules Users List Subject: Re: [rules-users] Rule one-by-one comparison Esteban, Thank you very much for that. I will look into it. Any other ideas, anyone? _ miguel 2011/8/26 Esteban Aliverti esteban.alive...@gmail.commailto:esteban.alive...@gmail.com You can try to use drools-verifier. This project basically lets you define rules about your rules. You can have a look at its tests to see how it works. You can get more info about drools-verifier here: http://community.jboss.org/wiki/DroolsVerifier And here you can see how are we using drools-verifier inside Guvnor: http://ilesteban.wordpress.com/2010/04/05/guvnors-field-constraints/ Best Regards, Esteban Aliverti - Developer @ http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com 2011/8/26 miguel machado mls.mach...@gmail.commailto:mls.mach...@gmail.com Hi there everybody, I need to perform rule comparison on a project I'm working on using drools expert 5.0. For a specific feature implementation, I have two different knowledge bases with several rules which I need to compare, one by one. By comparing, I mean inspect certain conditions within the LHS. Currently, I'm able to obtain several attributes from rules (org.drools.rule.Rule), such as the agenda-group and the rule name and a few others, but I haven't been able to do it all. Going deeper, there is LiteralConstraint (for simple conditions) which I can parse and obtain data. However, I don't know how to do it for OR-conditions, which I guess represents a MultiRestrictionFieldConstraint. Perhaps there is another way? I know this may seem like a very unorthodox thing to do, but I don't think there is a better way of comparing knowledge packages (except for full text comparison). Is there? Thanks in advance, _ miguel, PT -- To understand what is recursion you must first understand recursion ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users
[rules-users] Memory leak in 5.2/5.3
I'm in the middle of trying to upgrade our application to Drools 5.2 from 5.1 however I keep facing out of memory issues (I've also tried on the current 5.3 beta). I've simplified my code into the following test case which on my machine after about 600 or so iterations gives an Out of memory exception: @Test public void testCase() throws InterruptedException { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); for(int i = 0; i 1000; i++) { System.out.println(Run + i); StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession(); for(int j = 0; j 100; j++) { session.insert(new byte[10240]); } session.dispose(); session = null; System.gc(); } } Am I missing anything here - I'm calling session.dispose() which is all I believe is necessary when finishing the session, however using a profiler shows that all the StatefulKnowledgeSessionImpl and ReteooStatefulSessions are still present and therefore keeping hold of all the byte arrays and memory. Using a profiler it shows that the GC roots of the StatefulKnowledgeSessionImpl are kruntime of org.jbpm.process.instance.ProcessRuntimeImpl kruntime of org.jbpm.process.instance.event.DefaultSignalManager kruntime of org.jbpm.process.instance.timer.TimerManager kruntime of org.drools.reteoo.ReteooStatefulSession Similarly for the ReteooStatefulSession: session of org.drools.impl.StatefulKnowledgeSessionImpl session of org.drools.impl.StatefulKnowledgeSessionImpl workingMemory of org.jbpm.process.instance.ProcessRuntimeImpl workingMemory of org.jbpm.process.instance.ProcessRuntimeImpl workingMemory of org.jbpm.process.instance.ProcessRuntimeImpl Is this a known issue? Am I missing anything in my code above. I guess the alternative is to reuse my sessions - what is the most efficient way to remove all the facts from the working memory and get it back into a pristine state? Thanks, Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools 5.2 performance building KnowledgeBase
Cheers, thanks for the info, that does greatly improve compilation time - I take it it is your maxpermsize that you had to increase in jboss? Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of darktyco Sent: 24 August 2011 04:17 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Drools 5.2 performance building KnowledgeBase In case anyone else is struggling with this problem I found that using the latest beta mvel jar (beta 6) helps a lot. Performance and memory use building and loading my large KnowledgeBase is much better- on my slower machine I'm down to 20 minutes (from 60) of compile time. Not back to Drools 5.1 (10 minutes) speed. and I still have to give JBoss extra memory to deploy my webapp, but still much better. -- View this message in context: http://drools.46999.n3.nabble.com/Drools-5- 2-performance-building-KnowledgeBase-tp3239746p3279902.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Inconsistent syntax behaviour
Continuing trying to upgrade from drools 5.1 I've been finding some strange funnies in rules behavior. Currently I'm using droolsVersion5.3.0.Beta1/droolsVersion jbpmVersion5.1.0.Final/jbpmVersion mvelVersion2.1.Beta6/mvelVersion In our model we've got some lists (Yuck I know) and we want to test whether they are not empty, there are three variations of the rules that we could use rule TESTa when t : Title(t.getMyList().isEmpty() == false) then logger.debug(drools.getRule().getName() + + drools.getTuple()); end rule TESTb when t : Title(myList.isEmpty() == false) then logger.debug(drools.getRule().getName() + + drools.getTuple()); end rule TESTc when t : Title(myList.empty == false) then logger.debug(drools.getRule().getName() + + drools.getTuple()); end I'd expect all of these formats to work (particularly c) however only TESTa succeeds, the other two FAIL SILENTLY, failing to match anything but not generating any errors or warnings. Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Memory leak in 5.2/5.3
Swindells, Thomas píše v St 24. 08. 2011 v 09:14 +0100: I’ve simplified my code into the following test case which on my machine after about 600 or so iterations gives an Out of memory exception: Have you tried removing jBPM jar files? If it fixes the issue, then it's a known bug that should be already fixed on master (aka. Drools 5.3.) Unfortunately the fix didn't make Beta1. [Swindells, Thomas] We need it unfortunately, any idea when beta2 will be out? I've worked round it for now by reusing the sessions (cleaning out all the facts before I do so) but would be nice to get a proper fix :) It's also fixed on 5.2.x branch but I don't think there will be any further Drools releases from that. -- Lukáš Petrovický QE Lead, JBoss Enterprise BRMS Phone: +420 532 294 123 irc: lpetrovi, triceo Red Hat Czech, s. r. o. Purkyňova 99, 612 00 Brno, Czech Republic ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Detecting what fact/event properties have changed.
Drools doesn't know what has changed, the changes are all done in java code and it only knows something has been done to them when you call update, not what has been done (it could be nothing). There are three ways you could achieve this affect: 1. Keep an original copy of the data, when you get told of an update compare the original with the new ones (you can use something like Springs BeanWrapper to help you get access to the fields in a type unaware manner. 2. Make your classes produce PropertyChangeEvents to tell you what has changed. 3. Use Aspect Orientate programming to add an aspect on all the setters telling you when they have been called and what has changed. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of rp2 Sent: 19 August 2011 12:37 To: rules-users@lists.jboss.org Subject: [rules-users] Detecting what fact/event properties have changed. Currently drools supports listening to events when objects are inserted, updated or retracted. I would like to get information about a what properties have changed when the object was updated. Is there a way to do that? -- View this message in context: http://drools.46999.n3.nabble.com/Detecting- what-fact-event-properties-have-changed-tp3267788p3267788.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Regression 5.1-5.2 with conflicting ClassNames
I'm in the progress of updating from Drools 5.1 to 5.2 in the hope of solving problems we are having with intermittent mysteriously missing activations. I've found a regression with the compiler which I don't know whether anybody else has noticed before. In our application we've got two Content classes in different packages, and unfortunately one of our rule files has to reason over both of them. In drools 5.1 this was fine, we imported one of them and then used the fully qualified name for the other. I'm just upgrading to 5.2.0-Final and this no longer works. When resolving the unqualified class name drools/mvel(?) was choosing the package that we hadn't imported! This obviously then gave us loads of misleading error messages about not being able to find fields. Fully quallifiying all references to both classes fixed the issue but something obviously isn't behaving properly. Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] RuleAgent - loading rules help ?
Have you tried just using a file url? From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Ivan Peshev ( M-Tel ) Sent: 08 August 2011 11:04 To: rules-users@lists.jboss.org Subject: [rules-users] RuleAgent - loading rules help ? Hello, Is there a way to tell RuleAgent to load rules not only from remote URL ? i.e. some rules from URL and some rules from LOCAL path on my computer. (e.g.: c:\some\folder\rule.drl) Or if it's not possible exactly that way is there another way to have some rules loaded from URLs and some rules loaded from local path ? Best Regards Ivan ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] running multiple instance of rule engine
I’m not sure I understand the question. You have two totally independent rule engine on two different servers running with separate JVMs and sessions. You happen to share data between the two sessions by updating a database but drools has no knowledge of that (they are just java objects which happen to exist) and they certainly aren’t the same object on both servers. Temporal reasoning and correlation of events will therefore only happen on the facts that are inserted into that processes working memory – there’s no way it could be any way else as it only know about itself, there could be 10 or 0 other processes running it won’t know the difference. The ideal method is to have an application design where each request is totally independent from all other requests (other than db state) and therefore you do exactly as you have described – there is no other state to share. If you have to share state between them you have a much bigger problem and you probably have to find some other way to partition up the data into separate blocks. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Neelesh Deo Dani Sent: 02 August 2011 07:42 To: rules-users@lists.jboss.org Subject: [rules-users] running multiple instance of rule engine Hi, I need a setup where multiple instance of drools rule engine will be running in different physical hosts. In each host, a web server (API) will be running which will receive an input event, process it and insert into rule engine (session) for rules execution on the same host. I'm using external persistent datastore. The objects will be populated from datastore before inserting into the session. After rule execution if there is any change in the state of the objects the same will be stored back to the datastore. The datastore calls are made outside the rule execution. In this scenario, if an event comes to one host and another event comes to a different host, how will the temporal reasoning or correlation of events work? What is the recommended way of deploying multiple instance of rule engine for scalability? Please help in this regard. Thanks Regards, Neel ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] running multiple instance of rule engine
If you need all the events that are being generated then you need to have a session consume all the events that are being generated. If you can’t change that requirement then you are probably stuffed. You should explore partitioning your design in different ways. You may not need all the events generated in which case you could partition it so that different combinations of events go to different destinations. Alternatively you may be able to partition the logic. The first step consumes all the events but only has very simple logic to correlate and reduce the data produced. These correlations could then be farmed out to a stage 2 set of rules which no longer need the event stream or which now only need a subset of the event stream. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Neelesh Deo Dani Sent: 02 August 2011 12:12 To: Rules Users List Subject: Re: [rules-users] running multiple instance of rule engine It can be done in single session, if I make sure all the related events always go to a particular host by partitioning input event stream. Basically, I'm looking for options in a scenario when the number of input events per sec is very large and a single instance/ host won't be able to handle the events. In this case, we need to run multiple instance of rule engine to get the scale. Thanks, Neel --- On Tue, 2/8/11, Wolfgang Laun wolfgang.l...@gmail.commailto:wolfgang.l...@gmail.com wrote: From: Wolfgang Laun wolfgang.l...@gmail.commailto:wolfgang.l...@gmail.com Subject: Re: [rules-users] running multiple instance of rule engine To: Rules Users List rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org Date: Tuesday, 2 August, 2011, 4:11 PM Why don't you do it in a single session? The overhead created by the procedure you describe is considerable. And you may run into synchronisation problems such as that the first event has gone to host A, the second one goes to host B, but A hasn't stored the event yet... -W 2011/8/2 Neelesh Deo Dani neelesh...@yahoo.co.in/mc/compose?to=neelesh...@yahoo.co.in Following example clarifies the question: I've Event declaration and rule as follows: declare Event @role(event) @timestamp(datetime) datetime : Date name : String end rule Contest no-loop when $e1 : Event(name == event1) $e2 : Event(name == event2, this after $e1) then System.out.println(rule Contest fired); end If Event with name event1 is inserted in the session and after that Event with name event2 is inserted in the same session, then the temporal operator (this after $e1 ) will work fine. But, if these two events are inserted in two different sessions ( rule engine running on different host), then it won't work. I'm trying to find a solution for this scenario. One way is to persist the events as well in datastore and whenever any event comes, insert all the previous events also in the session (by fetching from datastore). In this example, when event2 comes (to host2), fetch event1 from datastore and insert it in the session so that temporal operator will work. Is there any better alternative exists for this scenario? Thanks, Neel --- On Tue, 2/8/11, Abhay B. Chaware abhay.chaw...@kpitcummins.com/mc/compose?to=abhay.chaw...@kpitcummins.com wrote: What do you expect to happen in the scenario mentioned, assuming you are running only 1 rules session? Whatever you expect to happen in this case ( e.g. latest update wins ), you will need to implement in your persistence logic If you are using separate rule engines/instances. by the way, have you looked at drools grid ? I haven’t used it, but appears to solve a similar problem that you are trying to – distributed computing. -abhay From: rules-users-boun...@lists.jboss.org/mc/compose?to=rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org/mc/compose?to=rules-users-boun...@lists.jboss.org] On Behalf Of Swindells, Thomas Sent: Tuesday, August 02, 2011 1:47 PM To: Rules Users List Subject: Re: [rules-users] running multiple instance of rule engine I’m not sure I understand the question. You have two totally independent rule engine on two different servers running with separate JVMs and sessions. You happen to share data between the two sessions by updating a database but drools has no knowledge of that (they are just java objects which happen to exist) and they certainly aren’t the same object on both servers. Temporal reasoning and correlation of events will therefore only happen on the facts that are inserted into that processes working memory – there’s no way it could be any way else as it only know about itself, there could be 10 or 0 other processes running it won’t know the difference. The ideal method is to have an application design where each request is totally independent from all other requests (other than db state) and therefore you
Re: [rules-users] How to reuse a result of a rule in an other rule
The latter approach is particularly powerful we have a very simple but amazingly flexible class called Affirmation which just have 3 fields - String name, Object subject, Object value. This however gives most flexibility that you need Eg rule Hungry when $person : Person(hoursSinceLunch2 || donutsOnDesk==0 || candybarsInDrawer==0) not Affirmation(name == PersonIsHungry, subject == $person) then insert(new Affirmation(PersonIsHungry, $person, true); end rule Food when $person : Person() Affirmation(name == PersonIsHungry, subject == $person, value == true) not Affirmation(name == PersonHasLookedForFood, subject == $person) then modify($person) { lookForFood() } insert(new Affirmation(PersonHasLookedForFood, $person)); end - I;ve also updated the rules so they are less likely to retrigger multiple times if some other rules modify person Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of mjohansen Sent: 21 July 2011 22:18 To: rules-users@lists.jboss.org Subject: Re: [rules-users] How to reuse a result of a rule in an other rule Basically, you can either update an object with the results of the first rule, or create a new object. Like: rule Hungry when $person : Person(hoursSinceLunch2 || donutsOnDesk==0 || candybarsInDrawer==0) then $person.setHungry(true); update($person); end rule Food when $person : Person(hungry==true) then $person.lookForFood() end or rule Hungry when $person : Person(hoursSinceLunch2 || donutsOnDesk==0 || candybarsInDrawer==0) then $hungry=new Hungry(); $hungry.setPerson($person); insert($hungry); end rule Food when $person : Person() $hungry : Hungry(person==$person) then $person.lookForFood() end -- View this message in context: http://drools.46999.n3.nabble.com/How-to- reuse-a-result-of-a-rule-in-an-other-rule-tp3182344p3189730.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Dynamic facts
My advice for designing datamodels and working with drools is to think of it as a database and follow standard database normalization procedures. Essentially drools in an in memory database which has a custom query and trigger syntax implemented in a very efficient manner! Each Object type is a table and each fact is a row in that table. Multiple conditions on different facts are a join between the tables. You wouldn't (generally) embed lists of addresses within the person table in the database, instead you'd have two separate tables for them as this makes updates and querying much more efficient. Generally with drools the only time you should be using the 'from' keyword or navigating through to child objects (person.homeAddress) is to write rules to extract those objects out and insert them as actual working memory facts. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 22 July 2011 08:06 To: Rules Users List Subject: Re: [rules-users] Dynamic facts On 22 July 2011 08:34, Marc Heinz marc.he...@no-log.orgmailto:marc.he...@no-log.org wrote: On 19 July 2011 13:42, Marc Heinz marc.he...@no-log.orgmailto:marc.he...@no-log.org wrote: So, despite I have only updated one attribute of the fact (the age of a Person), all rules have been fired again, even if they had nothing to do with the said attribute, which could possibly produce a huge overhead. I maybe misunderstood some basic concept here... But is there a way to prevent that? Reevaluation of all patterns referring to the type of a fact/object that has been changed is a fundamental principle of production rule systems. Ok, if I have well understood, my first assumption that I was trying to explain still holds: we should minimize dependencies between rules and fields from a single fact in order to have a finer granularity for updates... Which could effectively requires to dispatch a POJO internal structure into several other facts. I would not accept this as a design principle for Drools or similar RBS. Three reasons: 1. Drools (and its likes) have been built to cope with bean style objects, as the title of the classic paper puts it: Rete: A Fast Algorithm for the Many Pattern/Many Object Pattern Match Problem. 2. Splitting natural objects into facets with a small number of fields creates the necessity of adding properties for connecting these facts and using additional contstraints for combining them in rules. The cure might be worse than the (suspected) ailment. 3. Design should not squint at implementation issues of the underlying system; it should orientate itself on a model that represents the problem well. It could be that you haven't chosen the right platform for your application - but then you won't improve matters by jeopardizing your design. OK, that wraps it up. I assume that you'll continue as you have indicated. It might be interesting to hear about your experiences later on... Cheers -W Actually we were considering doing exactly the opposite in a first time: using enclosing classes extensively in order to make easier to provide some kind of structural constraint on the content of the knowledge base (such as: each values of this set should appears at most once in the knowledge base at any give time), but this is probably better done using the working memory in equality mode with custom equals methods. Thank you again for these precision :) Cheers, Marc ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Global variable in LHS
Don't use a global, instead create a new fact type Global having a single field globalVariable (type object will probably do), then you can pretty much write what you have below (once you add the missing bracket). Alternatively you may be able to do something like eval(Arrays.asList(X, Y).contains(globalVariable)) Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of pamerida Sent: 18 July 2011 19:09 To: rules-users@lists.jboss.org Subject: [rules-users] Global variable in LHS Hi everybody, I would like to analyze a global value in the LHS of my rule without using an eval, something like this: global String globalVariable; rule 'SI-002-NAD-6' salience 5000 when global (globalVariable in (X,Y) then logger.log([SI-002-NAD-6] Debe colocar la información del propietario del medio de transporte.); end I cant use eval because it doesnt recognize the keyword in, for example this code would throw me an error in the validation global String globalVariable; rule 'SI-002-NAD-6' salience 5000 when eval (globalVariable in (X,Y) then logger.log([SI-002-NAD-6] Debe colocar la información del propietario del medio de transporte.); end any suggestions? thanks so much for your help :) -- View this message in context: http://drools.46999.n3.nabble.com/Global- variable-in-LHS-tp3180063p3180063.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools and serialize
This looks wrong to me ByteArrayOutputStream baos = new ByteArrayOutputStream(); Marshaller marshaller = MarshallerFactory.newMarshaller( ksession.getKnowledgeBase(), new ObjectMarshallingStrategy[]{ oms } ); marshaller.marshall( baos, ksession ); ObjectOutputStream out = new ObjectOutputStream( baos ); out.writeObject( marshaller ); out.close(); Presumably the marshaller is writing out the knowledge session to the output stream, then you are trying to use an object output stream to output the marshaller you just used. I think in this case you need to use one or the other - either just write out the knowledgebase through the objectOutputStream, or write out the knowledge base with a custom marshaling strategy with the Marshaller, not both! Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Abhay B. Chaware Sent: 12 July 2011 11:46 To: Rules Users List Subject: Re: [rules-users] Drools and serialize Haven't used this before, but looks like DefaultMarshaller is not serializable. What I've done in past is directly serializing and deserializing knowledgebase without using Marshaller. That worked. -abhay -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of clement.pernot Sent: Tuesday, July 12, 2011 4:07 PM To: rules-users@lists.jboss.org Subject: Re: [rules-users] Drools and serialize I have try what you say. This didn't work. here is my full code: package com.sample; import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.drools.KnowledgeBase; import org.drools.KnowledgeBaseFactory; import org.drools.builder.KnowledgeBuilder; import org.drools.builder.KnowledgeBuilderError; import org.drools.builder.KnowledgeBuilderErrors; import org.drools.builder.KnowledgeBuilderFactory; import org.drools.builder.ResourceType; import org.drools.io.ResourceFactory; import org.drools.marshalling.Marshaller; import org.drools.marshalling.MarshallerFactory; import org.drools.marshalling.ObjectMarshallingStrategy; import org.drools.runtime.StatefulKnowledgeSession; public class test{ private static void compileRuleBase2( String drlPath, String rbPath ) throws Exception { KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kBuilder.add( ResourceFactory.newFileResource( drlPath ), ResourceType.DRL ); if( kBuilder.hasErrors() ){ for( KnowledgeBuilderError err: kBuilder.getErrors() ){ System.err.println( err.toString() ); } throw new IllegalStateException( DRL errors ); } KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(); kBase.addKnowledgePackages( kBuilder.getKnowledgePackages() ); try { KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); Message message = new Message(); message.setMessage(Hello World); message.setStatus(Message.HELLO); ksession.insert(message); ObjectMarshallingStrategy oms = MarshallerFactory.newIdentityMarshallingStrategy(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Marshaller marshaller = MarshallerFactory.newMarshaller( ksession.getKnowledgeBase(), new ObjectMarshallingStrategy[]{ oms } ); marshaller.marshall( baos, ksession ); ObjectOutputStream out = new ObjectOutputStream( baos ); out.writeObject( marshaller ); out.close(); baos.close(); ksession.fireAllRules(); } catch (Throwable t) { t.printStackTrace(); } } public static final void main(String[] args) { try { compileRuleBase2(Sample.drl, drools_compiled_file_with_fact ); } catch (Exception e) { e.printStackTrace(); } } private static KnowledgeBase readKnowledgeBase() throws Exception { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newClassPathResource(Sample.drl), ResourceType.DRL); KnowledgeBuilderErrors errors = kbuilder.getErrors(); if (errors.size() 0) { for (KnowledgeBuilderError error: errors) {
Re: [rules-users] Drools and serialize
You don't need the object output stream below - and it's very bad code to give access to the same output stream to two parents (the marshaller and the OOS in this case) as you can end up just writing garbage if they interleave their writes - you don't know the buffering policy that each parent is using. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of clement.pernot Sent: 12 July 2011 13:53 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Drools and serialize Thank you for all your tips. I think I have found the solution. (the project run) Now for test that, I try to make a project who can un-serialize this. There it is: package com.sample; import java.io.FileOutputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.Serializable; import org.drools.KnowledgeBase; import org.drools.KnowledgeBaseFactory; import org.drools.builder.KnowledgeBuilder; import org.drools.builder.KnowledgeBuilderError; import org.drools.builder.KnowledgeBuilderErrors; import org.drools.builder.KnowledgeBuilderFactory; import org.drools.builder.ResourceType; import org.drools.io.ResourceFactory; import org.drools.marshalling.Marshaller; import org.drools.marshalling.MarshallerFactory; import org.drools.marshalling.ObjectMarshallingStrategy; import org.drools.runtime.StatefulKnowledgeSession; /** * This is a sample class to launch a rule. */ public class test{ private static void compileRuleBase2( String drlPath, String rbPath ) throws Exception { KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kBuilder.add( ResourceFactory.newFileResource( drlPath ), ResourceType.DRL ); if( kBuilder.hasErrors() ){ for( KnowledgeBuilderError err: kBuilder.getErrors() ){ System.err.println( err.toString() ); } throw new IllegalStateException( DRL errors ); } KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(); kBase.addKnowledgePackages( kBuilder.getKnowledgePackages() ); try { // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); // go ! Message message = new Message(); message.setMessage(Hello World); message.setStatus(Message.HELLO); ksession.insert(message); ObjectMarshallingStrategy oms = MarshallerFactory.newIdentityMarshallingStrategy(); Marshaller marshaller = MarshallerFactory.newMarshaller( ksession.getKnowledgeBase(), new ObjectMarshallingStrategy[]{ oms } ); OutputStream os = new FileOutputStream( rbPath ); ObjectOutputStream oos = new ObjectOutputStream( os ); marshaller.marshall( os, ksession ); oos.close(); ksession.fireAllRules(); } catch (Throwable t) { t.printStackTrace(); } } public static final void main(String[] args) { try{ compileRuleBase2(Sample.drl, drools_compiled_file_with_fact ); } catch (Exception e) { e.printStackTrace(); } } private static KnowledgeBase readKnowledgeBase() throws Exception { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newClassPathResource(Sample.drl), ResourceType.DRL); KnowledgeBuilderErrors errors = kbuilder.getErrors(); if (errors.size() 0) { for (KnowledgeBuilderError error: errors) { System.err.println(error); } throw new IllegalArgumentException(Could not parse knowledge.); } KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); return kbase; } public static class Message implements Serializable{ public static final int HELLO = 0; public static final int GOODBYE = 1; private String message; private int status; public String getMessage() { return this.message; } public void setMessage(String message) { this.message = message; } public int getStatus() {
Re: [rules-users] FireAllRules and threads
You'd probably be better to use a batch command though containing the three commands rather than calling the methods on the ksession directly - it makes for slightly cleaner and more reliable integration from my experience. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 08 July 2011 13:35 To: Rules Users List Subject: Re: [rules-users] FireAllRules and threads On 8 July 2011 13:46, echirulli echiru...@gmail.commailto:echiru...@gmail.com wrote: Hi there, I've got a question regarding statefull session and threads. I searched a lot about this topic but I'm still a bit confused so... When a StatefullSession - fireAllRules() returns, can I be sure that the entire rules processing has ended? I red something about the fact that this is true unless rules inference happens, is it correct? No. A fireAllRules() returns after all of inference has happened and no more activations are eligible for firing. My simple purpose is to insert a fact into a statefullsession working memory, fire rules, wait until the end of rules processing and than retract that fact. How can i do it? FactHandle fh = kSession.insert( object ); kSession.fireAllRules(); kSession.retract( fh); -W Thank you Errico -- View this message in context: http://drools.46999.n3.nabble.com/FireAllRules-and-threads-tp3151572p3151572.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Can eval($param) be used as condition in the Spreadsheet decision table?
Yes, all the decision table compiler does is convert the cells into a drl file by doing some string manipulation, all it does with $param is do a string replace, so if you end up with a valid statement after the replacement has been done you can do whatever you like. Similar as you are suggesting some of our rules are constructed like field $param 0 where the cell values are either ==, = etc. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wishing Carebear Sent: 08 July 2011 14:54 To: Rules Users List Subject: [rules-users] Can eval($param) be used as condition in the Spreadsheet decision table? Is it possible to put eval($param) as Condition in the decision table so that the cells can have flexible values.? Thanks. ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] get inserted facts
Option 1 is to just use a stateful session - from my understanding there is pretty much no difference in terms of overhead. The other option is to insert a 'ResultsAccumulator' object containing a resultList. I If you don't need to reason over your new Facts than rather than inserting them just add them to the result list. Alternatively have a low salience rule which will only run at the end which accumulates up all the facts and adds them to the result list (either with accumulate or one by one). Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Ruault Gaetan Sent: 06 July 2011 01:13 To: Rules Users List Subject: [rules-users] get inserted facts Hi, I use drools in stateless Session like this : session.execute( my_facts_list) ; and i have many rules like this when Type1(filter1 =1) Then Insert( new Fact()) ; Could you explain how it's possible to retrieve my new facts in java code ? Thanks. Gaetan ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to update the working memory of a nested object attribute
You need a way to differentiate between policy's that have been updated and that haven't been updated. If you have control of your model then you could add an extra field, either as a flag or containing the new value - if this field is null you know you need to update it. If you can't change that part of the model you can introduce a new class PolicyUpdated(Service policy). When you update the policy you insert one of these. You then change your conditions to add not PolicyUpdated(policy == $policy) which will then stop you retriggering yourself. Finally you need to tell drools that you have modified Client. It may be more efficient to actually fetch and insert the policy service objects into the working memory, then you only need to tell drools/your rules that you have updated one small part of your rules rather than getting it to reiterate over all the services every update. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wishing Carebear Sent: 06 July 2011 04:47 To: Rules Users List Subject: [rules-users] How to update the working memory of a nested object attribute Hi, My rules update the nested object attributes :eligibilityScore which is used in another rule downstream. Only the Client object is sent as fact, the nested object is derived using the from keyword (list of services) rule Rule 8 EligibilityRating agenda-group EligibilityRating no-loop true salience 5 //dialect mvel when $client : Client(type == Preferred) $policy : Service(productType == Vehicle Insurance) from $client.service then System.out.println( Rule 8 ER = type == preferred:+ $policy.getId() + : -50); int eScore = $policy.getEligibilityScore() - 50; $policy.setEligibilityScore(eScore); // how to let the downstream rule know that this atribute value is updated without letting this current rule go into infinite loop end Any suggestion is greatly appreciated ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to update the working memory of a nested object attribute
Add a name into the policyUpdated type - each type of rule which should operate separately only references policyUpdates of that given name so you stop those from retriggering while allowing the others to trigger. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wishing Carebear Sent: 06 July 2011 14:17 To: Rules Users List Subject: Re: [rules-users] How to update the working memory of a nested object attribute Thanks Swindel. The eligibilityScore is updated on 3 different rules by decrementing the value if the condition is satisfied. Finally the eligibilityScore value is used in the downstream. Is there any pattern available for these types of use cases. 2011/7/6 Swindells, Thomas tswinde...@nds.commailto:tswinde...@nds.com You need a way to differentiate between policy's that have been updated and that haven't been updated. If you have control of your model then you could add an extra field, either as a flag or containing the new value - if this field is null you know you need to update it. If you can't change that part of the model you can introduce a new class PolicyUpdated(Service policy). When you update the policy you insert one of these. You then change your conditions to add not PolicyUpdated(policy == $policy) which will then stop you retriggering yourself. Finally you need to tell drools that you have modified Client. It may be more efficient to actually fetch and insert the policy service objects into the working memory, then you only need to tell drools/your rules that you have updated one small part of your rules rather than getting it to reiterate over all the services every update. Thomas From: rules-users-boun...@lists.jboss.orgmailto:rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.orgmailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wishing Carebear Sent: 06 July 2011 04:47 To: Rules Users List Subject: [rules-users] How to update the working memory of a nested object attribute Hi, My rules update the nested object attributes :eligibilityScore which is used in another rule downstream. Only the Client object is sent as fact, the nested object is derived using the from keyword (list of services) rule Rule 8 EligibilityRating agenda-group EligibilityRating no-loop true salience 5 //dialect mvel when $client : Client(type == Preferred) $policy : Service(productType == Vehicle Insurance) from $client.service then System.out.println( Rule 8 ER = type == preferred:+ $policy.getId() + : -50); int eScore = $policy.getEligibilityScore() - 50; $policy.setEligibilityScore(eScore); // how to let the downstream rule know that this atribute value is updated without letting this current rule go into infinite loop end Any suggestion is greatly appreciated ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.commailto:postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.orgmailto: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 Enumeration for long lists
How complex are the blacklist rules that you are planning to have? From what you have described it sounds like it is just substring/startswith matches? If this is the case then you may be better just to query lucene or the database directly as you'll result in a very flat extremely wide graph that drools isn't going to be able to optimize at all - it will basically just iterate over every string doing the string comparison. Lucene/the database are likely to be much more optimized and efficient for this. If on the other hand your blacklist logic is much more complicated, taking into account multiple criteria such as username, time of day, source ip address, phase of the moon etc then drools may be easier to optimize development speed and maintainance,. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of lansyj Sent: 05 July 2011 09:39 To: rules-users@lists.jboss.org Subject: [rules-users] Using Enumeration for long lists Hi, We are planning to use Drools for a Blacklist validation logic which requires us to manage very long list (could be tens of thousands of IDs). Can we use the native Drools enumeration for this? Would this be an optimal implementation? The other option we were thinking of was to have a list managed separately in our core application and have in lucene indexed such that Drools rule checks against the index. But, as you can see, it creates a lot of development as well as maintenance overhead. Thanks in advance for any tips on this topic. Best Regard -lj -- View this message in context: http://drools.46999.n3.nabble.com/Using- Enumeration-for-long-lists-tp3140051p3140051.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools in non-eclipse environment
Which version of drools is this? For drools 5.0.1 we just use maven to resolve the dependencies for us and it works fine. I can't obviously see any eclipse compiler in the jars that we distribute with our application. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Abhay B. Chaware Sent: 09 June 2011 08:06 To: rules-users@lists.jboss.org Subject: [rules-users] Drools in non-eclipse environment Has anyone tried using drools in non-eclipse env ? meaning that org.eclipse.jdt.core_3.5.1.v_972_R35x.jar is not in the classpath ? Documentation says this : (http://docs.huihoo.com/drools/4.0.7/ch02s05.html) if you do not have Eclipse JDT Core in your classpath you must override the compiler setting before you instantiate this PackageBuilder, you can either do that with a packagebuilder properties file the ChainedProperties class will find, or you can do it programmatically as shown below; note this time I use properties to inject the value for startup. They also provide an example, but I am not able to figure out exactly how to use this example/info. Here is my code : KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newInputStreamResource(is), ResourceType.DRL); where is is input stream containing the rule file ( .drl) How do I override the compiler setting ? I am getting a null pointer exception ( see below ) and I suspect that overriding the packagebuilderconfiguration will fix it ? W/System.err(25511): java.lang.NullPointerException W/System.err(25511):at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:47) W/System.err(25511):at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1161) W/System.err(25511):at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:637) W/System.err(25511):at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java :267) W/System.err(25511):at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder .java:459) W/System.err(25511):at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.ja va:28) W/System.err(25511):at com.ts.DBconnector.readKnowledgeBase(DBconnector.java:146) ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools in non-eclipse environment
If you precompile (using the maven-plugin of angkar out there), Are any details on this plugin available? - is it this one? http://passion.forco.de/content/maven-drools-plugin_overview What are peoples experiences of using it? Thanks, Thomas ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] What is contract between Heap Size and PermGen space
This is a pure java question not a drools question - I'd suggest you ask the experts on one of the java or jboss mailing lists! One question I'd have is whether you are running a 32 bit or 64bit jvm - if you are running a 32bit jvm then you will have limits on how much memory in total a process can address (including additional memory needed for the actual jvm, hotspot compiler etc). Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Satyendra Sharma Sent: 09 June 2011 11:05 To: rules-users@lists.jboss.org Subject: [rules-users] What is contract between Heap Size and PermGen space In my server Ram is 16GB but when 1. I tried to set max heap size to 2048MB in run.bat file and when started jboss server it thrown exception as Could not reserve enough space for object heap it accepted max 1336 mb. 2. and also JBoss server did not accept more than 128MB PermGen space but when I reduce the heap size from 1336 to 1024 it accepted PermGen space to max 256MB. Please let me know the reason when I have enough memory why it is not accepting heap size as 2048 and what is contract between heap size and PermGen space as reducing heap size helped PermGen space to increase. - Satyendra Sharma -- View this message in context: http://drools.46999.n3.nabble.com/What-is- contract-between-Heap-Size-and-PermGen-space-tp3043263p3043263.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Exception Handling in the rule
Firstly evals have to evaluate true or false - what you have here appears to return a string - presumably you are actually comparing this to some value? One, not particularly elegant or efficient method is to do the check within your eval, eg: eval(ClaimsHistoryHelper.getClaimDrug(drugRefNo) == null ? false : drugName == (ClaimsHistoryHelper.getClaimDrug(drugRefNo)).getDrugName()) If your ClaimsHistoryHelper is doing a time consuming operation (eg going to a db etc), you can probably make a very quick and simple efficiency saving by having it cache the last result it searched for/returned (or depending on how many drugRefNo you are looking up a more complete caching solution). Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of sdinoo Sent: 07 June 2011 06:22 To: rules-users@lists.jboss.org Subject: [rules-users] Exception Handling in the rule Hi, In my when clause I have an eval statement like this eval((ClaimsHistoryHelper.getClaimDrug(drugRefNo)).getDrugName()) For some reason, there is no DrugRecord for the given drugRefNo and hence I get javaNullPointer exceptions I do want to rule to continue evaluation and not stop with the error and hence I dont want to handle exception at fireAllRules catch block How can I handle the exception in the DRL ? -- View this message in context: http://drools.46999.n3.nabble.com/Exception- Handling-in-the-rule-tp3033223p3033223.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users