Re: [rules-users] Query regarding Upgrade to drools API 6.1.0
You just use the old classes when writing a 5.X application, and the new ones when writing a 6.X app. -- View this message in context: http://drools.46999.n3.nabble.com/Query-regarding-Upgrade-to-drools-API-6-1-0-tp4030736p4030738.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query on web services and database stuff
Firstly a correction. Drools rule engine otherwise known as Drools Expert does not use JCR by default. Guvnor (Drools rule authoring and management web applicafion) does use JCR as its persistent store. JCR is better thought of as a hierarchical data store than a (R)DBMS. That said Drools Expert can access databases and web services with the assistance of helper classes and the from keyword. The user guide will give fuller details. That said you are also free to retrieve Facts for insertion into Drools Expert from where- and however you like. sent on the move On 14 Feb 2013 07:34, starfish15 pooja.gh...@accenture.com wrote: Hello All, I am starting up on a project which requires Drools rules. I have been asked certain basic Q's. Am jotting them below 1. *Can the Drools Rule engine communicate to a DB * I know by default, drools does use the *Apache JackRabbit DB* to store respective assets and there are means to use other DBs as well. Not sure what else this Q could mean. So would really appreciate if some light can be thrown on this. What else things which could be achieved through the rules and DB connection 2. *Can the Drools Rule engine do web service calls to other system* I am not sure if this can be achieved through Drools. Would appreciate if some assistance could be provided on this and some working examples as well if this can actually be achieved. Regards, starfish -- View this message in context: http://drools.46999.n3.nabble.com/Query-on-web-services-and-database-stuff-tp4022294.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query on web services and database stuff
If you consider Drools Expert (the core engine) as a component, then certainly, yes, it can be integrated into a system that both utilizes persistence and communicates via web services in various ways respectively. As for working examples, I'm of the opinion that would be stretching the point of the mailing list, as these aren't concerns specific to Drools. Baking in these functionalities makes no sense (kitchen sink mentality, SoC) and providing examples of these would be to try and teach you fundamentals of architectural and enterprise design. This is akin to asking a car engine manufacturer how to create a steering mechanism and 6-passenger cabin, and provide examples of each. There are various approaches (patterns) that suit different needs, but none tie directly to the car engine. On Thu, Feb 14, 2013 at 2:13 AM, Michael Anstis michael.ans...@gmail.comwrote: Firstly a correction. Drools rule engine otherwise known as Drools Expert does not use JCR by default. Guvnor (Drools rule authoring and management web applicafion) does use JCR as its persistent store. JCR is better thought of as a hierarchical data store than a (R)DBMS. That said Drools Expert can access databases and web services with the assistance of helper classes and the from keyword. The user guide will give fuller details. That said you are also free to retrieve Facts for insertion into Drools Expert from where- and however you like. sent on the move On 14 Feb 2013 07:34, starfish15 pooja.gh...@accenture.com wrote: Hello All, I am starting up on a project which requires Drools rules. I have been asked certain basic Q's. Am jotting them below 1. *Can the Drools Rule engine communicate to a DB * I know by default, drools does use the *Apache JackRabbit DB* to store respective assets and there are means to use other DBs as well. Not sure what else this Q could mean. So would really appreciate if some light can be thrown on this. What else things which could be achieved through the rules and DB connection 2. *Can the Drools Rule engine do web service calls to other system* I am not sure if this can be achieved through Drools. Would appreciate if some assistance could be provided on this and some working examples as well if this can actually be achieved. Regards, starfish -- View this message in context: http://drools.46999.n3.nabble.com/Query-on-web-services-and-database-stuff-tp4022294.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 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query for a fact, and concurrent rule execution
Does each quote validation exercise enrich the StatefulKnowledgeSession with other facts that could influence validation of other quotes? If not probably using a StatefulKnowledgeSession per HTTP request might be more simple (with the KnowledgeBase as an application scoped variable). Regarding retrieval of results, there are a couple of options that spring to mind:- - Look at using a Global to collate results. - Look at using a Query ( http://stackoverflow.com/questions/5872215/how-do-i-add-facts-to-working-memory-at-runtime-in-the-drools-drl-and-retrieve-t ) With kind regards, Mike On 2 May 2012 10:39, stelomax stephen.lo...@mattelli.com wrote: Hi, Please bear with me, I am relatively new to the world of Drools and have a question. I am hoping it will be a simple issue. First let me frame my planned implementation at a high level. I am hoping to use Drools as a real time service enabled quote validation tool. Facts representing products and attributes will be loaded into a stateful knowledge session upon boot (using a piece of Java that loads these as facts from our product DB). The front-end application will allow users to build up quotes consisting of quote lines that make references to these products. Once the quote is built they will press a Validate button. This will call a webservice that will: 1) Insert the quote details as facts into the knowledge session 2) Run a rule flow to validate the quote against the product facts 3) The rules will insert validation results as facts tagged against the quote 4) QUERY for the validation results 5) Retract the facts for the quote (inc validation results) 6) Send the validation results back as a response to the webservice call My first question is how to implement step 4 -- how to physically query for the validation results pertaining to that specific quote. Any help here would be greatly appreciated. My second question relates to concurrency. As this is a quote validation tool there will be multiple users validating quotes so we will get concurrent validation requests. What is the recommended manner of dealing with concurrent rule requests within a stateful knowledge session. If 2 people attempt to validate a different quote at the same time we will have two quotes within the knowledge session together with all of the product facts. Is drools capable of running two concurrent rule flows against the knowledge session, each referencing a different quote or would we need to instantiate 2 knowledge sessions, or even deal with the matter in a serial manner placing the 2nd quote validation flow on hold until the first completes? Any help/pointers would be great. I am hoping someone out there has attempted to use Drools in a similar manner :) Many Thanks Ste -- View this message in context: http://drools.46999.n3.nabble.com/Query-for-a-fact-and-concurrent-rule-execution-tp3954737.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query for a fact, and concurrent rule execution
Hi Mike, Each quote does not enrich the session, we were actively looking to remove the quote at the end of the session to prevent it growing as we were just comparing the quote to the core product attribute facts. What is the performance hit in launching a Stateful knowledge session with say 10,000 facts, would it make the web service call slow? Thanks very much for the help on the query also…we will look into that. Kind Regards Ste On 2 May 2012, at 11:31, Michael Anstis wrote: Does each quote validation exercise enrich the StatefulKnowledgeSession with other facts that could influence validation of other quotes? If not probably using a StatefulKnowledgeSession per HTTP request might be more simple (with the KnowledgeBase as an application scoped variable). Regarding retrieval of results, there are a couple of options that spring to mind:- Look at using a Global to collate results. Look at using a Query (http://stackoverflow.com/questions/5872215/how-do-i-add-facts-to-working-memory-at-runtime-in-the-drools-drl-and-retrieve-t) With kind regards, Mike On 2 May 2012 10:39, stelomax stephen.lo...@mattelli.com wrote: Hi, Please bear with me, I am relatively new to the world of Drools and have a question. I am hoping it will be a simple issue. First let me frame my planned implementation at a high level. I am hoping to use Drools as a real time service enabled quote validation tool. Facts representing products and attributes will be loaded into a stateful knowledge session upon boot (using a piece of Java that loads these as facts from our product DB). The front-end application will allow users to build up quotes consisting of quote lines that make references to these products. Once the quote is built they will press a Validate button. This will call a webservice that will: 1) Insert the quote details as facts into the knowledge session 2) Run a rule flow to validate the quote against the product facts 3) The rules will insert validation results as facts tagged against the quote 4) QUERY for the validation results 5) Retract the facts for the quote (inc validation results) 6) Send the validation results back as a response to the webservice call My first question is how to implement step 4 -- how to physically query for the validation results pertaining to that specific quote. Any help here would be greatly appreciated. My second question relates to concurrency. As this is a quote validation tool there will be multiple users validating quotes so we will get concurrent validation requests. What is the recommended manner of dealing with concurrent rule requests within a stateful knowledge session. If 2 people attempt to validate a different quote at the same time we will have two quotes within the knowledge session together with all of the product facts. Is drools capable of running two concurrent rule flows against the knowledge session, each referencing a different quote or would we need to instantiate 2 knowledge sessions, or even deal with the matter in a serial manner placing the 2nd quote validation flow on hold until the first completes? Any help/pointers would be great. I am hoping someone out there has attempted to use Drools in a similar manner :) Many Thanks Ste -- View this message in context: http://drools.46999.n3.nabble.com/Query-for-a-fact-and-concurrent-rule-execution-tp3954737.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 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query for a fact, and concurrent rule execution
That's a possibility, but it'd depend on your rules. As a thought, you could serialise the initialised StatelessKnowledgeSession into a byte[] (cached at application scope) and deserialise with each web-service call. I would wait to see if Mark Proctor, Edson Tirelli or community members have other thoughts on use of a single StatefulKnowledgeSession. IIRC it is meant to be thread-safe but think people have reported problems in the past. Recently: http://lists.jboss.org/pipermail/rules-dev/2012-February/003857.html With kind regards, Mike On 2 May 2012 11:58, Stephen Lomax stephen.lo...@mattelli.com wrote: Hi Mike, Each quote does not enrich the session, we were actively looking to remove the quote at the end of the session to prevent it growing as we were just comparing the quote to the core product attribute facts. What is the performance hit in launching a Stateful knowledge session with say 10,000 facts, would it make the web service call slow? Thanks very much for the help on the query also…we will look into that. Kind Regards Ste On 2 May 2012, at 11:31, Michael Anstis wrote: Does each quote validation exercise enrich the StatefulKnowledgeSession with other facts that could influence validation of other quotes? If not probably using a StatefulKnowledgeSession per HTTP request might be more simple (with the KnowledgeBase as an application scoped variable). Regarding retrieval of results, there are a couple of options that spring to mind:- - Look at using a Global to collate results. - Look at using a Query ( http://stackoverflow.com/questions/5872215/how-do-i-add-facts-to-working-memory-at-runtime-in-the-drools-drl-and-retrieve-t ) With kind regards, Mike On 2 May 2012 10:39, stelomax stephen.lo...@mattelli.com wrote: Hi, Please bear with me, I am relatively new to the world of Drools and have a question. I am hoping it will be a simple issue. First let me frame my planned implementation at a high level. I am hoping to use Drools as a real time service enabled quote validation tool. Facts representing products and attributes will be loaded into a stateful knowledge session upon boot (using a piece of Java that loads these as facts from our product DB). The front-end application will allow users to build up quotes consisting of quote lines that make references to these products. Once the quote is built they will press a Validate button. This will call a webservice that will: 1) Insert the quote details as facts into the knowledge session 2) Run a rule flow to validate the quote against the product facts 3) The rules will insert validation results as facts tagged against the quote 4) QUERY for the validation results 5) Retract the facts for the quote (inc validation results) 6) Send the validation results back as a response to the webservice call My first question is how to implement step 4 -- how to physically query for the validation results pertaining to that specific quote. Any help here would be greatly appreciated. My second question relates to concurrency. As this is a quote validation tool there will be multiple users validating quotes so we will get concurrent validation requests. What is the recommended manner of dealing with concurrent rule requests within a stateful knowledge session. If 2 people attempt to validate a different quote at the same time we will have two quotes within the knowledge session together with all of the product facts. Is drools capable of running two concurrent rule flows against the knowledge session, each referencing a different quote or would we need to instantiate 2 knowledge sessions, or even deal with the matter in a serial manner placing the 2nd quote validation flow on hold until the first completes? Any help/pointers would be great. I am hoping someone out there has attempted to use Drools in a similar manner :) Many Thanks Ste -- View this message in context: http://drools.46999.n3.nabble.com/Query-for-a-fact-and-concurrent-rule-execution-tp3954737.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 ___ 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] Query for a fact, and concurrent rule execution
Hi Mike, Many thanks for that..we had previously thought of serialising to file but thought the purpose of the StatefulKnowledgeSession was to keep it live in memory continuously, rather than instantiating a new session with each web service call. My concern is that if we instantiate a new session with each web service call the memory required will increase massively (if we have many concurrent requests). Is there a way of serving multiple concurrent requests against the same session to remove that concern. Many thanks for your help with this..it is very much appreciated. Ste . On 2 May 2012, at 12:08, Michael Anstis wrote: That's a possibility, but it'd depend on your rules. As a thought, you could serialise the initialised StatelessKnowledgeSession into a byte[] (cached at application scope) and deserialise with each web-service call. I would wait to see if Mark Proctor, Edson Tirelli or community members have other thoughts on use of a single StatefulKnowledgeSession. IIRC it is meant to be thread-safe but think people have reported problems in the past. Recently: http://lists.jboss.org/pipermail/rules-dev/2012-February/003857.html With kind regards, Mike On 2 May 2012 11:58, Stephen Lomax stephen.lo...@mattelli.com wrote: Hi Mike, Each quote does not enrich the session, we were actively looking to remove the quote at the end of the session to prevent it growing as we were just comparing the quote to the core product attribute facts. What is the performance hit in launching a Stateful knowledge session with say 10,000 facts, would it make the web service call slow? Thanks very much for the help on the query also…we will look into that. Kind Regards Ste On 2 May 2012, at 11:31, Michael Anstis wrote: Does each quote validation exercise enrich the StatefulKnowledgeSession with other facts that could influence validation of other quotes? If not probably using a StatefulKnowledgeSession per HTTP request might be more simple (with the KnowledgeBase as an application scoped variable). Regarding retrieval of results, there are a couple of options that spring to mind:- Look at using a Global to collate results. Look at using a Query (http://stackoverflow.com/questions/5872215/how-do-i-add-facts-to-working-memory-at-runtime-in-the-drools-drl-and-retrieve-t) With kind regards, Mike On 2 May 2012 10:39, stelomax stephen.lo...@mattelli.com wrote: Hi, Please bear with me, I am relatively new to the world of Drools and have a question. I am hoping it will be a simple issue. First let me frame my planned implementation at a high level. I am hoping to use Drools as a real time service enabled quote validation tool. Facts representing products and attributes will be loaded into a stateful knowledge session upon boot (using a piece of Java that loads these as facts from our product DB). The front-end application will allow users to build up quotes consisting of quote lines that make references to these products. Once the quote is built they will press a Validate button. This will call a webservice that will: 1) Insert the quote details as facts into the knowledge session 2) Run a rule flow to validate the quote against the product facts 3) The rules will insert validation results as facts tagged against the quote 4) QUERY for the validation results 5) Retract the facts for the quote (inc validation results) 6) Send the validation results back as a response to the webservice call My first question is how to implement step 4 -- how to physically query for the validation results pertaining to that specific quote. Any help here would be greatly appreciated. My second question relates to concurrency. As this is a quote validation tool there will be multiple users validating quotes so we will get concurrent validation requests. What is the recommended manner of dealing with concurrent rule requests within a stateful knowledge session. If 2 people attempt to validate a different quote at the same time we will have two quotes within the knowledge session together with all of the product facts. Is drools capable of running two concurrent rule flows against the knowledge session, each referencing a different quote or would we need to instantiate 2 knowledge sessions, or even deal with the matter in a serial manner placing the 2nd quote validation flow on hold until the first completes? Any help/pointers would be great. I am hoping someone out there has attempted to use Drools in a similar manner :) Many Thanks Ste -- View this message in context: http://drools.46999.n3.nabble.com/Query-for-a-fact-and-concurrent-rule-execution-tp3954737.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query for a fact, and concurrent rule execution
I would suggest making your service stateless and run the service in multiple JVMs to alleviate performance concerns. You will be able to scale and also not have to worry about cramming everything into a StatefulKnowledgeSession and worry abt thead-safety. From: Stephen Lomax stephen.lo...@mattelli.com To: Rules Users List rules-users@lists.jboss.org, Date: 05/02/2012 04:28 AM Subject:Re: [rules-users] Query for a fact, and concurrent rule execution Sent by:rules-users-boun...@lists.jboss.org Hi Mike, Many thanks for that..we had previously thought of serialising to file but thought the purpose of the StatefulKnowledgeSession was to keep it live in memory continuously, rather than instantiating a new session with each web service call. My concern is that if we instantiate a new session with each web service call the memory required will increase massively (if we have many concurrent requests). Is there a way of serving multiple concurrent requests against the same session to remove that concern. Many thanks for your help with this..it is very much appreciated. Ste . On 2 May 2012, at 12:08, Michael Anstis wrote: That's a possibility, but it'd depend on your rules. As a thought, you could serialise the initialised StatelessKnowledgeSession into a byte[] (cached at application scope) and deserialise with each web-service call. I would wait to see if Mark Proctor, Edson Tirelli or community members have other thoughts on use of a single StatefulKnowledgeSession. IIRC it is meant to be thread-safe but think people have reported problems in the past. Recently: http://lists.jboss.org/pipermail/rules-dev/2012-February/003857.html With kind regards, Mike On 2 May 2012 11:58, Stephen Lomax stephen.lo...@mattelli.com wrote: Hi Mike, Each quote does not enrich the session, we were actively looking to remove the quote at the end of the session to prevent it growing as we were just comparing the quote to the core product attribute facts. What is the performance hit in launching a Stateful knowledge session with say 10,000 facts, would it make the web service call slow? Thanks very much for the help on the query also…we will look into that. Kind Regards Ste On 2 May 2012, at 11:31, Michael Anstis wrote: Does each quote validation exercise enrich the StatefulKnowledgeSession with other facts that could influence validation of other quotes? If not probably using a StatefulKnowledgeSession per HTTP request might be more simple (with the KnowledgeBase as an application scoped variable). Regarding retrieval of results, there are a couple of options that spring to mind:- Look at using a Global to collate results. Look at using a Query ( http://stackoverflow.com/questions/5872215/how-do-i-add-facts-to-working-memory-at-runtime-in-the-drools-drl-and-retrieve-t ) With kind regards, Mike On 2 May 2012 10:39, stelomax stephen.lo...@mattelli.com wrote: Hi, Please bear with me, I am relatively new to the world of Drools and have a question. I am hoping it will be a simple issue. First let me frame my planned implementation at a high level. I am hoping to use Drools as a real time service enabled quote validation tool. Facts representing products and attributes will be loaded into a stateful knowledge session upon boot (using a piece of Java that loads these as facts from our product DB). The front-end application will allow users to build up quotes consisting of quote lines that make references to these products. Once the quote is built they will press a Validate button. This will call a webservice that will: 1) Insert the quote details as facts into the knowledge session 2) Run a rule flow to validate the quote against the product facts 3) The rules will insert validation results as facts tagged against the quote 4) QUERY for the validation results 5) Retract the facts for the quote (inc validation results) 6) Send the validation results back as a response to the webservice call My first question is how to implement step 4 -- how to physically query for the validation results pertaining to that specific quote. Any help here would be greatly appreciated. My second question relates to concurrency. As this is a quote validation tool there will be multiple users validating quotes so we will get concurrent validation requests. What is the recommended manner of dealing with concurrent rule requests within a stateful knowledge session. If 2 people attempt to validate a different quote at the same time we will have two quotes within the knowledge session together with all of the product facts. Is drools capable of running two concurrent rule flows against the knowledge session, each referencing a different quote or would we need to instantiate 2 knowledge sessions, or even deal with the matter in a serial manner placing the 2nd quote validation flow on hold until the first completes? Any help/pointers would be great. I am hoping someone
Re: [rules-users] Query for a fact, and concurrent rule execution
Loading a stateless knowledge session with ~10k facts and the one (or few) transaction fact(s) for a single transaction isn't economic. I'd benchmark the costs for inserting the transaction fact(s) into a statefeul session, run fireAllRules(), returning the result and removing the debris in a thread. This should give you a good indication how many of these you can do per second, and the potential delay for concurrent requests when transactions are done in turn. -W On 02/05/2012, gpa...@tsys.com gpa...@tsys.com wrote: I would suggest making your service stateless and run the service in multiple JVMs to alleviate performance concerns. You will be able to scale and also not have to worry about cramming everything into a StatefulKnowledgeSession and worry abt thead-safety. From: Stephen Lomax stephen.lo...@mattelli.com To: Rules Users List rules-users@lists.jboss.org, Date: 05/02/2012 04:28 AM Subject:Re: [rules-users] Query for a fact, and concurrent rule execution Sent by:rules-users-boun...@lists.jboss.org Hi Mike, Many thanks for that..we had previously thought of serialising to file but thought the purpose of the StatefulKnowledgeSession was to keep it live in memory continuously, rather than instantiating a new session with each web service call. My concern is that if we instantiate a new session with each web service call the memory required will increase massively (if we have many concurrent requests). Is there a way of serving multiple concurrent requests against the same session to remove that concern. Many thanks for your help with this..it is very much appreciated. Ste . On 2 May 2012, at 12:08, Michael Anstis wrote: That's a possibility, but it'd depend on your rules. As a thought, you could serialise the initialised StatelessKnowledgeSession into a byte[] (cached at application scope) and deserialise with each web-service call. I would wait to see if Mark Proctor, Edson Tirelli or community members have other thoughts on use of a single StatefulKnowledgeSession. IIRC it is meant to be thread-safe but think people have reported problems in the past. Recently: http://lists.jboss.org/pipermail/rules-dev/2012-February/003857.html With kind regards, Mike On 2 May 2012 11:58, Stephen Lomax stephen.lo...@mattelli.com wrote: Hi Mike, Each quote does not enrich the session, we were actively looking to remove the quote at the end of the session to prevent it growing as we were just comparing the quote to the core product attribute facts. What is the performance hit in launching a Stateful knowledge session with say 10,000 facts, would it make the web service call slow? Thanks very much for the help on the query also…we will look into that. Kind Regards Ste On 2 May 2012, at 11:31, Michael Anstis wrote: Does each quote validation exercise enrich the StatefulKnowledgeSession with other facts that could influence validation of other quotes? If not probably using a StatefulKnowledgeSession per HTTP request might be more simple (with the KnowledgeBase as an application scoped variable). Regarding retrieval of results, there are a couple of options that spring to mind:- Look at using a Global to collate results. Look at using a Query ( http://stackoverflow.com/questions/5872215/how-do-i-add-facts-to-working-memory-at-runtime-in-the-drools-drl-and-retrieve-t ) With kind regards, Mike On 2 May 2012 10:39, stelomax stephen.lo...@mattelli.com wrote: Hi, Please bear with me, I am relatively new to the world of Drools and have a question. I am hoping it will be a simple issue. First let me frame my planned implementation at a high level. I am hoping to use Drools as a real time service enabled quote validation tool. Facts representing products and attributes will be loaded into a stateful knowledge session upon boot (using a piece of Java that loads these as facts from our product DB). The front-end application will allow users to build up quotes consisting of quote lines that make references to these products. Once the quote is built they will press a Validate button. This will call a webservice that will: 1) Insert the quote details as facts into the knowledge session 2) Run a rule flow to validate the quote against the product facts 3) The rules will insert validation results as facts tagged against the quote 4) QUERY for the validation results 5) Retract the facts for the quote (inc validation results) 6) Send the validation results back as a response to the webservice call My first question is how to implement step 4 -- how to physically query for the validation results pertaining to that specific quote. Any help here would be greatly appreciated. My second question relates to concurrency. As this is a quote validation tool there will be multiple users validating quotes so we will get concurrent validation requests. What is the recommended manner
Re: [rules-users] Query for a fact, and concurrent rule execution
Hi Wolfgang Thanks for the response. We will build a quick environment with test facts and run a benchmark as you suggest. If we can fire these through quick enough then this sounds like the preferred approach. Then my next issue will be how to allow users to insert product updates through the day and release new price lists without impacting users calling the validation service ;-/ Thanks for all the help Ste On 2 May 2012, at 17:09, Wolfgang Laun wrote: Loading a stateless knowledge session with ~10k facts and the one (or few) transaction fact(s) for a single transaction isn't economic. I'd benchmark the costs for inserting the transaction fact(s) into a statefeul session, run fireAllRules(), returning the result and removing the debris in a thread. This should give you a good indication how many of these you can do per second, and the potential delay for concurrent requests when transactions are done in turn. -W On 02/05/2012, gpa...@tsys.com gpa...@tsys.com wrote: I would suggest making your service stateless and run the service in multiple JVMs to alleviate performance concerns. You will be able to scale and also not have to worry about cramming everything into a StatefulKnowledgeSession and worry abt thead-safety. From: Stephen Lomax stephen.lo...@mattelli.com To: Rules Users List rules-users@lists.jboss.org, Date: 05/02/2012 04:28 AM Subject:Re: [rules-users] Query for a fact, and concurrent rule execution Sent by:rules-users-boun...@lists.jboss.org Hi Mike, Many thanks for that..we had previously thought of serialising to file but thought the purpose of the StatefulKnowledgeSession was to keep it live in memory continuously, rather than instantiating a new session with each web service call. My concern is that if we instantiate a new session with each web service call the memory required will increase massively (if we have many concurrent requests). Is there a way of serving multiple concurrent requests against the same session to remove that concern. Many thanks for your help with this..it is very much appreciated. Ste . On 2 May 2012, at 12:08, Michael Anstis wrote: That's a possibility, but it'd depend on your rules. As a thought, you could serialise the initialised StatelessKnowledgeSession into a byte[] (cached at application scope) and deserialise with each web-service call. I would wait to see if Mark Proctor, Edson Tirelli or community members have other thoughts on use of a single StatefulKnowledgeSession. IIRC it is meant to be thread-safe but think people have reported problems in the past. Recently: http://lists.jboss.org/pipermail/rules-dev/2012-February/003857.html With kind regards, Mike On 2 May 2012 11:58, Stephen Lomax stephen.lo...@mattelli.com wrote: Hi Mike, Each quote does not enrich the session, we were actively looking to remove the quote at the end of the session to prevent it growing as we were just comparing the quote to the core product attribute facts. What is the performance hit in launching a Stateful knowledge session with say 10,000 facts, would it make the web service call slow? Thanks very much for the help on the query also…we will look into that. Kind Regards Ste On 2 May 2012, at 11:31, Michael Anstis wrote: Does each quote validation exercise enrich the StatefulKnowledgeSession with other facts that could influence validation of other quotes? If not probably using a StatefulKnowledgeSession per HTTP request might be more simple (with the KnowledgeBase as an application scoped variable). Regarding retrieval of results, there are a couple of options that spring to mind:- Look at using a Global to collate results. Look at using a Query ( http://stackoverflow.com/questions/5872215/how-do-i-add-facts-to-working-memory-at-runtime-in-the-drools-drl-and-retrieve-t ) With kind regards, Mike On 2 May 2012 10:39, stelomax stephen.lo...@mattelli.com wrote: Hi, Please bear with me, I am relatively new to the world of Drools and have a question. I am hoping it will be a simple issue. First let me frame my planned implementation at a high level. I am hoping to use Drools as a real time service enabled quote validation tool. Facts representing products and attributes will be loaded into a stateful knowledge session upon boot (using a piece of Java that loads these as facts from our product DB). The front-end application will allow users to build up quotes consisting of quote lines that make references to these products. Once the quote is built they will press a Validate button. This will call a webservice that will: 1) Insert the quote details as facts into the knowledge session 2) Run a rule flow to validate the quote against the product facts 3) The rules will insert validation results as facts tagged against the quote 4) QUERY for the validation results 5) Retract
Re: [rules-users] Query for a fact, and concurrent rule execution
Indeed! And there's no reason you couldn't do the procedure below with multiple concurrent stateful sessions. In fact, this might be the best way, as when the support facts change you could create new sessions and not disrupt the service. (And if the support facts are immutable and not changed by the rules you should share them between sessions in the same JVM, saving memory and DB load overhead.) --- On Wed, 5/2/12, Wolfgang Laun wolfgang.l...@gmail.com wrote: From: Wolfgang Laun wolfgang.l...@gmail.com Subject: Re: [rules-users] Query for a fact, and concurrent rule execution To: Rules Users List rules-users@lists.jboss.org Date: Wednesday, May 2, 2012, 11:09 AM Loading a stateless knowledge session with ~10k facts and the one (or few) transaction fact(s) for a single transaction isn't economic. I'd benchmark the costs for inserting the transaction fact(s) into a statefeul session, run fireAllRules(), returning the result and removing the debris in a thread. This should give you a good indication how many of these you can do per second, and the potential delay for concurrent requests when transactions are done in turn. -W On 02/05/2012, gpa...@tsys.com gpa...@tsys.com wrote: I would suggest making your service stateless and run the service in multiple JVMs to alleviate performance concerns. You will be able to scale and also not have to worry about cramming everything into a StatefulKnowledgeSession and worry abt thead-safety. From: Stephen Lomax stephen.lo...@mattelli.com To: Rules Users List rules-users@lists.jboss.org, Date: 05/02/2012 04:28 AM Subject: Re: [rules-users] Query for a fact, and concurrent rule execution Sent by: rules-users-boun...@lists.jboss.org Hi Mike, Many thanks for that..we had previously thought of serialising to file but thought the purpose of the StatefulKnowledgeSession was to keep it live in memory continuously, rather than instantiating a new session with each web service call. My concern is that if we instantiate a new session with each web service call the memory required will increase massively (if we have many concurrent requests). Is there a way of serving multiple concurrent requests against the same session to remove that concern. Many thanks for your help with this..it is very much appreciated. Ste . On 2 May 2012, at 12:08, Michael Anstis wrote: That's a possibility, but it'd depend on your rules. As a thought, you could serialise the initialised StatelessKnowledgeSession into a byte[] (cached at application scope) and deserialise with each web-service call. I would wait to see if Mark Proctor, Edson Tirelli or community members have other thoughts on use of a single StatefulKnowledgeSession. IIRC it is meant to be thread-safe but think people have reported problems in the past. Recently: http://lists.jboss.org/pipermail/rules-dev/2012-February/003857.html With kind regards, Mike On 2 May 2012 11:58, Stephen Lomax stephen.lo...@mattelli.com wrote: Hi Mike, Each quote does not enrich the session, we were actively looking to remove the quote at the end of the session to prevent it growing as we were just comparing the quote to the core product attribute facts. What is the performance hit in launching a Stateful knowledge session with say 10,000 facts, would it make the web service call slow? Thanks very much for the help on the query also…we will look into that. Kind Regards Ste On 2 May 2012, at 11:31, Michael Anstis wrote: Does each quote validation exercise enrich the StatefulKnowledgeSession with other facts that could influence validation of other quotes? If not probably using a StatefulKnowledgeSession per HTTP request might be more simple (with the KnowledgeBase as an application scoped variable). Regarding retrieval of results, there are a couple of options that spring to mind:- Look at using a Global to collate results. Look at using a Query ( http://stackoverflow.com/questions/5872215/how-do-i-add-facts-to-working-memory-at-runtime-in-the-drools-drl-and-retrieve-t ) With kind regards, Mike On 2 May 2012 10:39, stelomax stephen.lo...@mattelli.com wrote: Hi, Please bear with me, I am relatively new to the world of Drools and have a question. I am hoping it will be a simple issue. First let me frame my planned implementation at a high level. I am hoping to use Drools as a real time service enabled quote validation tool. Facts representing products and attributes will be loaded into a stateful knowledge session upon boot (using a piece of Java that loads these as facts from our product DB). The front-end application will allow users to build up quotes consisting of quote lines that make references to these products. Once the quote is built
Re: [rules-users] query created in guvnor 5.3.0.final does not return expected results
You'd get this result even when there's no query with the name string you use in the API call. (1) Make sure that the name is correct. (2) Make sure that there is a query with that name, e.g., by inspecting the session's knowledge base at runtime. -W On 28/01/2012, vadlam sreeram.vadlam...@wellsfargo.com wrote: I have created a query in guvnor 5.3 in a separate drl file as follows. query get total Documents created document : Document( ) end I have several rules that create Documents as part of the ruleflow. on the java side ksession.fireAllRules(new RuleFilter()); // the rulefilter does not really do anything except log the //rules executing org.drools.runtime.rule.QueryResults results = ksession.getQueryResults(get total Documents created); System.out.println( we have + results.size() + Documents ); I see that the returned results size is 0 but the following code returns the documents as expected. Collection responseObjects = ksession.getObjects(); is there anything I am missing with respect to the query ? I use a ruleflow . does the query need to be part of any of the ruleflowgroups within the ruleflow ? is there a way to know whether the query ran or not ? -- View this message in context: http://drools.46999.n3.nabble.com/query-created-in-guvnor-5-3-0-final-does-not-return-expected-results-tp3695002p3695002.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] query in drools expert :: rule language
Hi luane, thanks for that. Using the expression under eval() solves the problem. I don't develop the objects I am applying the rule against. So I have to make do with string datatype. cheers. -- View this message in context: http://drools.46999.n3.nabble.com/query-in-drools-expert-rule-language-tp3612345p3612444.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] query in drools expert :: rule language
The Drools version would be interesting, to raise a JIRA if it is 5.2.0. -W On 26 December 2011 09:05, bobbi_80 guruprasad_bo...@infosys.com wrote: Hi luane, thanks for that. Using the expression under eval() solves the problem. I don't develop the objects I am applying the rule against. So I have to make do with string datatype. cheers. -- View this message in context: http://drools.46999.n3.nabble.com/query-in-drools-expert-rule-language-tp3612345p3612444.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] query in drools expert :: rule language
sorry forgot to mention that part. I am using 5.3.0 final. -- View this message in context: http://drools.46999.n3.nabble.com/query-in-drools-expert-rule-language-tp3612345p3612453.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] query in drools expert :: rule language
Starting with Drools 5.2, general boolean expressions should work, but there were problems. Which version are you using? Why doesn't averageCPU have a numeric type? Then the comparison would be straightforward (and most efficient). To be on the safe side with String, use $cpuUsage : cpuTracker( eval( Integer.parseInt($cpuUsage.getAverageCPU()) 60 ) ) -W On 26 December 2011 06:50, bobbi_80 guruprasad_bo...@infosys.com wrote: Hi , I want to know if there is any way I can evaluate a string in rule language. Here is what I am doing DroolsTest.java has a class as follows. DroolsTest.java public static class cpuTracker{ private String machinename; private String averageCPU; } I want to set a rule in sample.drl such that if the averageCPU is greater than 80 an action is taken. Sample.drl rule High CPU Usage when $cpuUsage : cpuTracker( Integer.parseInt(averageCPU) 60 ) then System.out.println(CPU usage is very high!!); end The compiler throws the following error *no viable alternative at averageCPU for rule High CPu usage*. I am unable to convert string to int using Inetger.parseInt(). Any idea why it is throwing me an error and any help with rule language syntax that I can get online? Can't find all the answers from http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html_single/index.html Any help is highly appreciated. -- View this message in context: http://drools.46999.n3.nabble.com/query-in-drools-expert-rule-language-tp3612345p3612345.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query in stateless knowledge session - SOLVED
Mark, Thanks for your help! I was finally able to test, and that totally worked. I was confused by example 3.37 (4.37 in the Drools 5.2.0 docs). The key point I missed must be that newStartProcess causes all the rules to fire. Well, at least I was right about it being something simple. :-) Best, Hank On Jul 31, 2011, at 12:47 PM, Mark Proctor wrote: On 31/07/2011 17:45, Mark Proctor wrote: On 31/07/2011 17:25, Heijink, Hank wrote: Aha! I missed the line about the dispose. That makes a lot of sense. What I don't understand is why the example 3.37 in the docs would work. If I understand what you're saying, it shouldn't. It should work, as long as the query is executed as part of the same execute batch. We have unit tests f or that too somewhere. ok I see the problem. Your rules will not fire until the all the command shave been executed. i.e. the implicit fireAllRules() is once all commands have been executed. Which means the query will be invoked before your rule fires to insert the object. Instead you need to add the FireAllRules command before executing the query. Mark mark Thanks! Hank Sent from my iPhone On Jul 30, 2011, at 8:27 AM, Wolfgang Laun wolfgang.l...@gmail.com wrote: StatelessKnowledgeSession.execute(...) executes the command(s) and finally calls dispose() on the session. Use a stateful session or a global (filled with a low-salience rule) or - simply use the getObjects command. -W On 29 July 2011 22:47, Heijink, Hank heij...@audible.com wrote: Hi all, I'm new to Drools, so please excuse me if I'm asking about the obvious--it's certainly not obvious to me. The problem is this: I use a stateless knowledge session where a list of facts is inserted. The rules that fire create new facts, and after all the rules have fired, I'd like to obtain a list of all the facts (the old and the new). The best way seemed to use a query. I'm using Drools 5.1 on Linux. The logger shows me that the BadgeState object is created, but the query returns an empty list. I've searched the documentation, which suggests that I'm doing it right (http://drools.herod.net/drools-expert/html/ch03.html#d0e1956, example 3.37), the archives of this mailinglist, and the web, so far without success. Clearly, I'm missing something, and I have the nagging feeling that it's something simple... Any help is much appreciated! Best, Hank ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query in stateless knowledge session returns no results
Aha! I missed the line about the dispose. That makes a lot of sense. What I don't understand is why the example 3.37 in the docs would work. If I understand what you're saying, it shouldn't. Thanks! Hank Sent from my iPhone On Jul 30, 2011, at 8:27 AM, Wolfgang Laun wolfgang.l...@gmail.commailto:wolfgang.l...@gmail.com wrote: StatelessKnowledgeSession.execute(...) executes the command(s) and finally calls dispose() on the session. Use a stateful session or a global (filled with a low-salience rule) or - simply use the getObjects command. -W On 29 July 2011 22:47, Heijink, Hank mailto:heij...@audible.comheij...@audible.commailto:heij...@audible.com wrote: Hi all, I'm new to Drools, so please excuse me if I'm asking about the obvious--it's certainly not obvious to me. The problem is this: I use a stateless knowledge session where a list of facts is inserted. The rules that fire create new facts, and after all the rules have fired, I'd like to obtain a list of all the facts (the old and the new). The best way seemed to use a query. I'm using Drools 5.1 on Linux. This is part of my .drl file (without the imports): rule create badge when Event ( eventType == EventType.SOME_EVENT_TYPE ) not BadgeState ( identifier == badge ) then insert( new BadgeState(badge) ); end query all badges aBadge : BadgeState() end This is the Java code: StatelessKnowledgeSession ksession = StatsKnowledgeBase.getKnowledgeBase().newStatelessKnowledgeSession(); // Create a list of share events ArrayListEvent events = new ArrayListEvent(); Date now = new Date(); MobileDevice aDevice = new MobileDevice(uniqueId, deviceType); for (int i = 0; i 5; i++) { Event anEvent = new Event.Builder(now, aDevice, aCustomer, EventType.SOME_EVENT_TYPE).build(); events.add(anEvent); } // Create the query for the badges ListCommand commands = new ArrayListCommand(); commands.add(CommandFactory.newInsertElements(events)); commands.add(CommandFactory.newQuery(all badges, all badges)); // Feed the events into Drools KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession); ExecutionResults results = ksession.execute( CommandFactory.newBatchExecution(commands) ); NativeQueryResults queryResults = (NativeQueryResults)results.getValue(all badges); // At this point, queryResults is empty. logger.close(); // Get a list of badges ListBadgeState badges = new ArrayListBadgeState(); for (IteratorQueryResultsRow i = queryResults.iterator(); i.hasNext(); ) { QueryResultsRow result = i.next(); BadgeState obj = (BadgeState)result.get(aBadge); badges.add(obj); } The logger shows me that the BadgeState object is created, but the query returns an empty list. I've searched the documentation, which suggests that I'm doing it right (http://drools.herod.net/drools-expert/html/ch03.html#d0e1956http://drools.herod.net/drools-expert/html/ch03.html#d0e1956, example 3.37), the archives of this mailinglist, and the web, so far without success. Clearly, I'm missing something, and I have the nagging feeling that it's something simple... Any help is much appreciated! Best, Hank ___ rules-users mailing list mailto:rules-users@lists.jboss.orgrules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-usershttps://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.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query in stateless knowledge session returns no results
On 31/07/2011 17:25, Heijink, Hank wrote: Aha! I missed the line about the dispose. That makes a lot of sense. What I don't understand is why the example 3.37 in the docs would work. If I understand what you're saying, it shouldn't. It should work, as long as the query is executed as part of the same execute batch. We have unit tests f or that too somewhere. mark Thanks! Hank Sent from my iPhone On Jul 30, 2011, at 8:27 AM, Wolfgang Laun wolfgang.l...@gmail.com mailto:wolfgang.l...@gmail.com wrote: StatelessKnowledgeSession.execute(...) executes the command(s) and /finally calls dispose()/ on the session. Use a stateful session or a global (filled with a low-salience rule) or - simply use the getObjects command. -W On 29 July 2011 22:47, Heijink, Hank heij...@audible.com mailto:heij...@audible.com wrote: Hi all, I'm new to Drools, so please excuse me if I'm asking about the obvious--it's certainly not obvious to me. The problem is this: I use a stateless knowledge session where a list of facts is inserted. The rules that fire create new facts, and after all the rules have fired, I'd like to obtain a list of all the facts (the old and the new). The best way seemed to use a query. I'm using Drools 5.1 on Linux. This is part of my .drl file (without the imports): rule create badge when Event ( eventType == EventType.SOME_EVENT_TYPE ) not BadgeState ( identifier == badge ) then insert( new BadgeState(badge) ); end query all badges aBadge : BadgeState() end This is the Java code: StatelessKnowledgeSession ksession = StatsKnowledgeBase.getKnowledgeBase().newStatelessKnowledgeSession(); // Create a list of share events ArrayListEvent events = new ArrayListEvent(); Date now = new Date(); MobileDevice aDevice = new MobileDevice(uniqueId, deviceType); for (int i = 0; i 5; i++) { Event anEvent = new Event.Builder(now, aDevice, aCustomer, EventType.SOME_EVENT_TYPE).build(); events.add(anEvent); } // Create the query for the badges ListCommand commands = new ArrayListCommand(); commands.add(CommandFactory.newInsertElements(events)); commands.add(CommandFactory.newQuery(all badges, all badges)); // Feed the events into Drools KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession); ExecutionResults results = ksession.execute( CommandFactory.newBatchExecution(commands) ); NativeQueryResults queryResults = (NativeQueryResults)results.getValue(all badges); // At this point, queryResults is empty. logger.close(); // Get a list of badges ListBadgeState badges = new ArrayListBadgeState(); for (IteratorQueryResultsRow i = queryResults.iterator(); i.hasNext(); ) { QueryResultsRow result = i.next(); BadgeState obj = (BadgeState)result.get(aBadge); badges.add(obj); } The logger shows me that the BadgeState object is created, but the query returns an empty list. I've searched the documentation, which suggests that I'm doing it right (http://drools.herod.net/drools-expert/html/ch03.html#d0e1956, example 3.37), the archives of this mailinglist, and the web, so far without success. Clearly, I'm missing something, and I have the nagging feeling that it's something simple... Any help is much appreciated! Best, Hank ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query in stateless knowledge session returns no results
On 31/07/2011 17:45, Mark Proctor wrote: On 31/07/2011 17:25, Heijink, Hank wrote: Aha! I missed the line about the dispose. That makes a lot of sense. What I don't understand is why the example 3.37 in the docs would work. If I understand what you're saying, it shouldn't. It should work, as long as the query is executed as part of the same execute batch. We have unit tests f or that too somewhere. ok I see the problem. Your rules will not fire until the all the command shave been executed. i.e. the implicit fireAllRules() is once all commands have been executed. Which means the query will be invoked before your rule fires to insert the object. Instead you need to add the FireAllRules command before executing the query. Mark mark Thanks! Hank Sent from my iPhone On Jul 30, 2011, at 8:27 AM, Wolfgang Laun wolfgang.l...@gmail.com mailto:wolfgang.l...@gmail.com wrote: StatelessKnowledgeSession.execute(...) executes the command(s) and /finally calls dispose()/ on the session. Use a stateful session or a global (filled with a low-salience rule) or - simply use the getObjects command. -W On 29 July 2011 22:47, Heijink, Hank heij...@audible.com mailto:heij...@audible.com wrote: Hi all, I'm new to Drools, so please excuse me if I'm asking about the obvious--it's certainly not obvious to me. The problem is this: I use a stateless knowledge session where a list of facts is inserted. The rules that fire create new facts, and after all the rules have fired, I'd like to obtain a list of all the facts (the old and the new). The best way seemed to use a query. I'm using Drools 5.1 on Linux. This is part of my .drl file (without the imports): rule create badge when Event ( eventType == EventType.SOME_EVENT_TYPE ) not BadgeState ( identifier == badge ) then insert( new BadgeState(badge) ); end query all badges aBadge : BadgeState() end This is the Java code: StatelessKnowledgeSession ksession = StatsKnowledgeBase.getKnowledgeBase().newStatelessKnowledgeSession(); // Create a list of share events ArrayListEvent events = new ArrayListEvent(); Date now = new Date(); MobileDevice aDevice = new MobileDevice(uniqueId, deviceType); for (int i = 0; i 5; i++) { Event anEvent = new Event.Builder(now, aDevice, aCustomer, EventType.SOME_EVENT_TYPE).build(); events.add(anEvent); } // Create the query for the badges ListCommand commands = new ArrayListCommand(); commands.add(CommandFactory.newInsertElements(events)); commands.add(CommandFactory.newQuery(all badges, all badges)); // Feed the events into Drools KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession); ExecutionResults results = ksession.execute( CommandFactory.newBatchExecution(commands) ); NativeQueryResults queryResults = (NativeQueryResults)results.getValue(all badges); // At this point, queryResults is empty. logger.close(); // Get a list of badges ListBadgeState badges = new ArrayListBadgeState(); for (IteratorQueryResultsRow i = queryResults.iterator(); i.hasNext(); ) { QueryResultsRow result = i.next(); BadgeState obj = (BadgeState)result.get(aBadge); badges.add(obj); } The logger shows me that the BadgeState object is created, but the query returns an empty list. I've searched the documentation, which suggests that I'm doing it right (http://drools.herod.net/drools-expert/html/ch03.html#d0e1956, example 3.37), the archives of this mailinglist, and the web, so far without success. Clearly, I'm missing something, and I have the nagging feeling that it's something simple... Any help is much appreciated! Best, Hank ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org
Re: [rules-users] Query in stateless knowledge session returns no results
Thanks so much! I'll have a chance to test it tomorrow. Hank Sent from my iPhone On Jul 31, 2011, at 12:48 PM, Mark Proctor mproc...@codehaus.orgmailto:mproc...@codehaus.org wrote: On 31/07/2011 17:45, Mark Proctor wrote: On 31/07/2011 17:25, Heijink, Hank wrote: Aha! I missed the line about the dispose. That makes a lot of sense. What I don't understand is why the example 3.37 in the docs would work. If I understand what you're saying, it shouldn't. It should work, as long as the query is executed as part of the same execute batch. We have unit tests f or that too somewhere. ok I see the problem. Your rules will not fire until the all the command shave been executed. i.e. the implicit fireAllRules() is once all commands have been executed. Which means the query will be invoked before your rule fires to insert the object. Instead you need to add the FireAllRules command before executing the query. Mark mark Thanks! Hank Sent from my iPhone On Jul 30, 2011, at 8:27 AM, Wolfgang Laun mailto:wolfgang.l...@gmail.comwolfgang.l...@gmail.commailto:wolfgang.l...@gmail.com wrote: StatelessKnowledgeSession.execute(...) executes the command(s) and finally calls dispose() on the session. Use a stateful session or a global (filled with a low-salience rule) or - simply use the getObjects command. -W On 29 July 2011 22:47, Heijink, Hank mailto:heij...@audible.comheij...@audible.commailto:heij...@audible.com wrote: Hi all, I'm new to Drools, so please excuse me if I'm asking about the obvious--it's certainly not obvious to me. The problem is this: I use a stateless knowledge session where a list of facts is inserted. The rules that fire create new facts, and after all the rules have fired, I'd like to obtain a list of all the facts (the old and the new). The best way seemed to use a query. I'm using Drools 5.1 on Linux. This is part of my .drl file (without the imports): rule create badge when Event ( eventType == EventType.SOME_EVENT_TYPE ) not BadgeState ( identifier == badge ) then insert( new BadgeState(badge) ); end query all badges aBadge : BadgeState() end This is the Java code: StatelessKnowledgeSession ksession = StatsKnowledgeBase.getKnowledgeBase().newStatelessKnowledgeSession(); // Create a list of share events ArrayListEvent events = new ArrayListEvent(); Date now = new Date(); MobileDevice aDevice = new MobileDevice(uniqueId, deviceType); for (int i = 0; i 5; i++) { Event anEvent = new Event.Builder(now, aDevice, aCustomer, EventType.SOME_EVENT_TYPE).build(); events.add(anEvent); } // Create the query for the badges ListCommand commands = new ArrayListCommand(); commands.add(CommandFactory.newInsertElements(events)); commands.add(CommandFactory.newQuery(all badges, all badges)); // Feed the events into Drools KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession); ExecutionResults results = ksession.execute( CommandFactory.newBatchExecution(commands) ); NativeQueryResults queryResults = (NativeQueryResults)results.getValue(all badges); // At this point, queryResults is empty. logger.close(); // Get a list of badges ListBadgeState badges = new ArrayListBadgeState(); for (IteratorQueryResultsRow i = queryResults.iterator(); i.hasNext(); ) { QueryResultsRow result = i.next(); BadgeState obj = (BadgeState)result.get(aBadge); badges.add(obj); } The logger shows me that the BadgeState object is created, but the query returns an empty list. I've searched the documentation, which suggests that I'm doing it right (http://drools.herod.net/drools-expert/html/ch03.html#d0e1956http://drools.herod.net/drools-expert/html/ch03.html#d0e1956, example 3.37), the archives of this mailinglist, and the web, so far without success. Clearly, I'm missing something, and I have the nagging feeling that it's something simple... Any help is much appreciated! Best, Hank ___ rules-users mailing list mailto:rules-users@lists.jboss.orgrules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-usershttps://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list mailto:rules-users@lists.jboss.orgrules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-usershttps://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list
Re: [rules-users] Query in stateless knowledge session returns no results
StatelessKnowledgeSession.execute(...) executes the command(s) and *finally calls dispose()* on the session. Use a stateful session or a global (filled with a low-salience rule) or - simply use the getObjects command. -W On 29 July 2011 22:47, Heijink, Hank heij...@audible.com wrote: Hi all, I'm new to Drools, so please excuse me if I'm asking about the obvious--it's certainly not obvious to me. The problem is this: I use a stateless knowledge session where a list of facts is inserted. The rules that fire create new facts, and after all the rules have fired, I'd like to obtain a list of all the facts (the old and the new). The best way seemed to use a query. I'm using Drools 5.1 on Linux. This is part of my .drl file (without the imports): rule create badge when Event ( eventType == EventType.SOME_EVENT_TYPE ) not BadgeState ( identifier == badge ) then insert( new BadgeState(badge) ); end query all badges aBadge : BadgeState() end This is the Java code: StatelessKnowledgeSession ksession = StatsKnowledgeBase.getKnowledgeBase().newStatelessKnowledgeSession(); // Create a list of share events ArrayListEvent events = new ArrayListEvent(); Date now = new Date(); MobileDevice aDevice = new MobileDevice(uniqueId, deviceType); for (int i = 0; i 5; i++) { Event anEvent = new Event.Builder(now, aDevice, aCustomer, EventType.SOME_EVENT_TYPE).build(); events.add(anEvent); } // Create the query for the badges ListCommand commands = new ArrayListCommand(); commands.add(CommandFactory.newInsertElements(events)); commands.add(CommandFactory.newQuery(all badges, all badges)); // Feed the events into Drools KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession); ExecutionResults results = ksession.execute( CommandFactory.newBatchExecution(commands) ); NativeQueryResults queryResults = (NativeQueryResults)results.getValue(all badges); // At this point, queryResults is empty. logger.close(); // Get a list of badges ListBadgeState badges = new ArrayListBadgeState(); for (IteratorQueryResultsRow i = queryResults.iterator(); i.hasNext(); ) { QueryResultsRow result = i.next(); BadgeState obj = (BadgeState)result.get(aBadge); badges.add(obj); } The logger shows me that the BadgeState object is created, but the query returns an empty list. I've searched the documentation, which suggests that I'm doing it right ( http://drools.herod.net/drools-expert/html/ch03.html#d0e1956, example 3.37), the archives of this mailinglist, and the web, so far without success. Clearly, I'm missing something, and I have the nagging feeling that it's something simple... Any help is much appreciated! Best, Hank ___ 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] Query query...
Are you setting the status attribute in the RHS of a rule? Are you updating the facts after you modify them? Best, Esteban Aliverti - Developer @ http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com 2010/11/9 Dennis Duggan den...@esptechnologies.com I have 2 types of objects in my knowledge base that I am trying to equate. Equality is based on a number of different variables contained in the objects. Once I find equal objects I set a status member in each to “Matched”, otherwise it will be “OneKnows” or “TwoKnows”. After I fire the rules I use queries that I call from Java code to get the three different types of objects. *query* OneFirmKnows oRecord : MyObject1( status==OneKnows ) *end* *query* TwoKnows oRecord : MyObject2( status==TwoKnows ) *end* *query* Matched oRecord : MyObject1( status==Matched ) *end* Each query sends back all objects no matter what the status is. The objects have a getStatus( ) method. What am I doing wrong? Thanks! Dennis ___ 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] Query query...
How are classes MyObject1 and MyObject2 related? Is there a field status in each of them and/or in their common superclass? -W 2010/11/9 Dennis Duggan den...@esptechnologies.com I have 2 types of objects in my knowledge base that I am trying to equate. Equality is based on a number of different variables contained in the objects. Once I find equal objects I set a status member in each to “Matched”, otherwise it will be “OneKnows” or “TwoKnows”. After I fire the rules I use queries that I call from Java code to get the three different types of objects. *query* OneFirmKnows oRecord : MyObject1( status==OneKnows ) *end* *query* TwoKnows oRecord : MyObject2( status==TwoKnows ) *end* *query* Matched oRecord : MyObject1( status==Matched ) *end* Each query sends back all objects no matter what the status is. The objects have a getStatus( ) method. What am I doing wrong? Thanks! Dennis ___ 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] Query query...
I have a super interface, that both objects implement. The matching rule looks like: rule Match when $oRecord1 : MyObject1( ) $oRecord2 : MyObject2(RefID==$oRecord1. RefID ) then $oRecord1.setStatus( Matched ); $oRecord2.setStatus( Matched ); end I can breakpoint right after running the query and I see objects with all statuses so the matching rule is firing correctly. Thanks! Dennis Dennis Duggan Principal Software Engineer, Software Engineering ESP Technologies Corp. THE Buy-Side Solution One Indian Head Plaza Suite 701, Nashua, NH 03060 603.324.2444 ext. 1304 Office | 603.324.2447 Fax den...@esptechnologies.com ESP Technologies, winner 2009 Red Herring North America 100 and 2008 Deloitte Technology Fast 500. This e-mail and/or attachments may contain privileged, confidential or proprietary information. Unintended recipients should notify the sender immediately and delete. Disclosure, copying, distribution or use of this e-mail or any attachment is prohibited. Brokerage services provided by Electronic Securities Processing (ESP) LLC. Member FINRA, SIPC. This is neither an offer or recommendation to buy or sell any security or other financial instrument. Email complia...@esptechnologies.com with questions regarding this disclosure. From: Dennis Duggan Sent: Tuesday, November 09, 2010 1:55 PM To: 'rules-users@lists.jboss.org' Subject: Query query... I have 2 types of objects in my knowledge base that I am trying to equate. Equality is based on a number of different variables contained in the objects. Once I find equal objects I set a status member in each to Matched, otherwise it will be OneKnows or TwoKnows. After I fire the rules I use queries that I call from Java code to get the three different types of objects. query OneFirmKnows oRecord : MyObject1( status==OneKnows ) end query TwoKnows oRecord : MyObject2( status==TwoKnows ) end query Matched oRecord : MyObject1( status==Matched ) end Each query sends back all objects no matter what the status is. The objects have a getStatus( ) method. What am I doing wrong? Thanks! Dennis ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query query...
You don't call modify or update on $oRecord1/$oRecord2! -W 2010/11/9 Dennis Duggan den...@esptechnologies.com I have a super interface, that both objects implement. The matching rule looks like: *rule* Match *when* $oRecord1 : MyObject1( ) $oRecord2 : MyObject2(RefID==$oRecord1. RefID ) *then* $oRecord1.setStatus( Matched ); $oRecord2.setStatus( Matched ); *end* I can breakpoint right after running the query and I see objects with all statuses so the matching rule is firing correctly. Thanks! Dennis Dennis Duggan Principal Software Engineer, Software Engineering ESP Technologies Corp. THE Buy-Side Solution** One Indian Head Plaza Suite 701, Nashua, NH 03060 603.324.2444 ext. 1304 Office | 603.324.2447 Fax den...@esptechnologies.com *ESP Technologies, winner 2009 Red Herring North America 100 and 2008 Deloitte Technology Fast 500*.** This e-mail and/or attachments may contain privileged, confidential or proprietary information. Unintended recipients should notify the sender immediately and delete. Disclosure, copying, distribution or use of this e-mail or any attachment is prohibited. Brokerage services provided by Electronic Securities Processing (ESP) LLC. Member FINRA, SIPC. This is neither an offer or recommendation to buy or sell any security or other financial instrument. Email complia...@esptechnologies.com with questions regarding this disclosure. *From:* Dennis Duggan *Sent:* Tuesday, November 09, 2010 1:55 PM *To:* 'rules-users@lists.jboss.org' *Subject:* Query query... I have 2 types of objects in my knowledge base that I am trying to equate. Equality is based on a number of different variables contained in the objects. Once I find equal objects I set a status member in each to “Matched”, otherwise it will be “OneKnows” or “TwoKnows”. After I fire the rules I use queries that I call from Java code to get the three different types of objects. *query* OneFirmKnows oRecord : MyObject1( status==OneKnows ) *end* *query* TwoKnows oRecord : MyObject2( status==TwoKnows ) *end* *query* Matched oRecord : MyObject1( status==Matched ) *end* Each query sends back all objects no matter what the status is. The objects have a getStatus( ) method. What am I doing wrong? Thanks! Dennis ___ 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] Query about Drools
Hi, 1) Outside of Guvnor rules are normally defined in DRL (text files) or spreadsheets (Decision Tables). There is an API to load these into KnowledgeBases at runtime. Behind the covers Guvnor does much the same - generating DRL from its internal structures that are compiled into KnowledgeBases to be downloaded. Is XML essential or can DRL suffice? I believe there is a proprietary XML format however I am uncertain how well supported this is. I believe the plan is to migrate to RulesML at sometime. 2) You could look at using KnowledgeAgent which supports scanning and retrieving Knowledge artefacts from a single (central) location. You could also consider using a distributed cache in which serialisable KnowledgeBases could be stored. I think there are other users that use Terracotta in a clustered environment to support Drools but I don't know the detail. With kind regards, Mike On 1 November 2010 09:38, sameer.bogawat sameer.boga...@gmail.com wrote: I have a project where I am allowing users to create rules from the application UI. Currently all the rules related info is stored in a database and the rules matching code is in Java. However this slows down the application considerably and hence we are looking at using a third party rules engine. I have the following queries : 1. Is it possible to use the backend APIs (if any) to create/modify rules in XML files in Drools on the fly i.e. at runtime ? We do not want to use the Guvnor UI to create/modify rules. 2. We would be using a clustered environment , so is there any readymade webservice which will update the rules at one location (from where the other nodes can refer data). Any help with the above queries would be of great help. Do let me know in case you require extra information. Thanks in Advance ! -Sameer -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Query-about-Drools-tp1820824p1820824.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query about performance in using data as fact or using it as Global variable
I cannot tell from what you have posted; but without relating member to company you run the risk of producing a Cartesian product of results which would, no doubt, give you a performance problem. rule Cartesian product when $c : Company() $m : Member() then //Joined all Companies to all Members. Ouch! end rule Join 1 when $c : Company() $m : Member(company == $c) then //Nice end rule Join 2 when $c : Company() $m : Member() from $c.members then //Nice end Rule Join 2 should enable you to only insert Company's into working memory too. 2010/10/15 Nikhil S. Kulkarni nikhil.kulka...@mastek.com Hi , I am using drools 5.0 in application. I am facing performance issues. I am using drls, rule flows and rule templates. My scenario is as follows :- Consider there is list of 20 companies. There are about 2 members in each company. Now I have several rules in which condition is for specific member and specific company. e.g. rule 1 when comp : company and member : Members then ……… End; So similarly I passed Member list and company list as fact. But it was time consuming process. So I have done one change. I kept only comp:company in when condition of rule as I explained above and declare member list as global . I created a function in rule in which I am iterating over member list and doing the same process. Now this is taking less time. Now my question is how efficient is this change. Though we say that when we write specific condition in rule then it will be fired only in that case. But when I use Agenda Event Listener class, I come to know one thing that it creates activation-created for all possible conditions then it will fire activation-Fired for specific condition And after that it will cancel all the activations. So as I reduced member level fact condition my time is reduced drastically and performance improved. So anybody can suggest me that whether I am on right track of improving time and performance or not ? Waiting for reply. *Thanks Regards,* *Nikhil S. Kulkarni* * * MASTEK LTD. In the US, we're called MAJESCOMASTEK ~~ Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server. ~~ ___ 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] Query about performance in using data as fact or using it as Global variable
For this sort of analysis one has to know (1) whether one Member can be a member of a single company only, or whether (s)he can be a member of more than one, too; (2) (assuming it's N:1) whether is is possible to have a reference to the company as a field in each Member object (3) whether you can or cannot (for whatever reason) insert indovodual Company objects as single facts into WM: (4) whether you can or cannot (for whatever reason) insert individual Member objects as single facts into WM: (5) whether matching for an individual Member is possible by a unique identification of that Member or whether it is only possible in combination with the member's company (employee IDs are only unique within a Company) Best performance for rules where you have to search for a Member with employeeId in a Company with name can be achieved by s.th. like the rule shown below, where I assume that Member:Comp is N:1 and Member contains a reference to his/her Company: rule when LookFor( $comp : comp, $empId : empId ) $c: Company( name == $comp ) $m: Member( comp == $c, empId == $empId ) then ... -W 2010/10/15 Nikhil S. Kulkarni nikhil.kulka...@mastek.com Hi , I am using drools 5.0 in application. I am facing performance issues. I am using drls, rule flows and rule templates. My scenario is as follows :- Consider there is list of 20 companies. There are about 2 members in each company. Now I have several rules in which condition is for specific member and specific company. e.g. rule 1 when comp : company and member : Members then ……… End; So similarly I passed Member list and company list as fact. But it was time consuming process. So I have done one change. I kept only comp:company in when condition of rule as I explained above and declare member list as global . I created a function in rule in which I am iterating over member list and doing the same process. Now this is taking less time. Now my question is how efficient is this change. Though we say that when we write specific condition in rule then it will be fired only in that case. But when I use Agenda Event Listener class, I come to know one thing that it creates activation-created for all possible conditions then it will fire activation-Fired for specific condition And after that it will cancel all the activations. So as I reduced member level fact condition my time is reduced drastically and performance improved. So anybody can suggest me that whether I am on right track of improving time and performance or not ? Waiting for reply. *Thanks Regards,* *Nikhil S. Kulkarni* * * MASTEK LTD. In the US, we're called MAJESCOMASTEK ~~ Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server. ~~ ___ 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] Query on Performance Improvement in Drools 5 while dealing with huge data
correcting the format. -- Hi There, We are using Drools 5 in our project, the requirement was to have huge database, the data is being fetched from DB and inserted into drools working memory. For eg: Cell - 50k ExternalCell - 50k CellRelation - 250 Topology hiearchy: -Subnetwork - PLMN (Contained in Subnetwork) - RNC (Contained in PLMN) - Cells (Contained in RNC) Problem statement: Check if bidirectional relation not exist between cells in different subnetwork. How to prove? Prove that, First check: - CellObA and ExternalCellObB in subnetwork 1, both are related using CellRelationX. - Unidirectional note: CellObA will have ListString property contains all ExternalCellOb names, so ExternalCellObB name should be part of List if there is an CellRelation relating CellObA and ExternalCellObB. Second check: - CellObB and ExternalCellObA in subnetwork 2, both are related using CellRelationY. - Unidirectional (inturn proves that bi-directional relation exist) note: CellObB will have ListString property contains all ExternalCellOb names, so similarly ExternalCellObA should be part of List if there is an CellRelation relating CellObB and ExternalCellObA. Check if there is missing/no relation exist between CellObB and ExteranlCellObA. Cell table has oneToMany relation to CellRelation table. We are using eclipselink for ORM, since Cell and CellRelation tables are related, while reteriving Cell, CellRelation are also part of the it (using fetch.type = LAZY). Since Cell table is kind of master table, we are creating the required objects by from cell entities and inserting the newly created objects into working memory. Cell table contains master data and ExternalCell table contains proxy (duplicate copy of master) data. Mapping from Entities to Objects Entity - Objects -- Cell- CellOb ExternalCell - ExternalCellOb CellRelation - CellRelation CellOb ExternalCellOb contains following attributes which are used for comparison. - mcc,mnc,rncId,cellId and nodeId are all of type integer used for comparsion. - mcc, mnc, rncId and cellId are used to uniquely identify CellOb and its ExternalCellOb through object equality. These fours attributes are used in overrided equals() and hashcode() method. -- Rule file: rule Cell Selection Rule salience 50 dialect java when $ucell:CellOb() from TopologyService.getInstance().getCellObs() then insert($ucell); // inserts each CellOb into working memory. end rule External Cell Selection Rule salience 49 dialect java when $extucell:ExternalCellOb() from TopologyService.getInstance().getExternalCellObs() then insert($extucell); // inserts each ExternalCellOb into working memory. end rule Bidirectional Relations Evaluation Rule salience 10 dialect java when //Takes ExternalCellObB from Subnetwork 1 $extuccell : ExternalCellOb(subnetworkMgrId==1) // Takes CellObA from Subnetwork 1, not matching cgiParam (is mcc+mnc+rncId+cellId) of ExternalCellObB, and seeing if there is CellRelation exist // between ExternalCellObB and CellObA using contains check $cell : CellObA(subnetworkMgrId==$extuccell.subnetworkMgrId,cgiParam!=$extuccell.cgiParam,adjacentCells contains $extuccell.fdnReverse) //Takes ExternalCellObA from Subnetwork 2, matching CellObA cgiParam (is mcc+mnc+rncId+cellId) $adjextcell : ExternalCellOb (subnetworkMgrId!=$cell.subnetworkMgrId, cgiParam==$cell.cgiParam) //Takes CellObB from Subnetwork 2, matching ExternalCellObB, and seeing if there is no CellRelation exist between CellObB and //ExternalCellObA $adjcell : CellOb ( subnetworkMgrId==$adjextcell.subnetworkMgrId, cgiParam==$extuccell.cgiParam,adjacentCells not contains $adjextcell.fdnReverse) then // FDN format looks like the one mentioned below. // SubNetwork=ROOT_OB,SubNetwork=1,Context=01,MElement=1,Rnc=1,Cell=RNC01-104 System.out.println(Missing Cell Relation from + $cell.getFdn() + to + $adjcell.getFdn()); end -- Tried following and gave performance imporvements after each change: - Initially, we use to check the following attributes individually, like mcc, mnc, rncId and cellId but later we combined and it gave some performance improvements. - Used subnetworkId to search CellOb/ExternalCellOb with in a appropriate subnetwork. - Java string search trick, cellNames are very lengthy but they vary at the end of the string, so reverse the string and it improved in the contains/not contains check in the List of strings. What we wanted to know is from Drools part any
Re: [rules-users] Query on loading facts dynamically
If you want to reward all students you'll have to have all students in WM, at one time or other. Assuming that you aren't dealing with all the students in China, it doesn't matter much how you do this. Now as for a student's exams, there might be an advantage if you could restrict the set of facts to those that are actually required to compute the average of last 3 out of all. But to fetch just these, you'd have to know some key (e.g., student+course) - but I don't see how you can construct that without having the exam object with all its attributes, especially the date. Regards -W 2010/6/30 jobin wilson jobinwil...@gmail.com Hello List, I have a very basic question about inserting facts into the working memory dynamically.For firing the rules,we should be having all our facts in the working memory.In that case,How will we deal with the situation where the facts that we need for evaluation of a particular rule is dependent on the rule itself (needs to be brought it dynamically)? Say for example say i want to use rule engine to reward all students with average scores for all subjects 75 for the past 3 exams. The facts that i have are the Student objects their Subject wise scores(one to many relation;one student to many exams each exams having many subjects). I want the when condition to be satisfied for all students whose average scores for all subjects for the past 3 exams to be greater than 75 and the consequence to be to just print out the name of the student. In this case,should i be loading all the student objects each of their past exam scores in the whole system to find student objects satisfying this critera? Since i already know that the rule just need the average scores for just the past 3 exams for each student,wouldn't loading the whole facts be inefficient? Is there a way in which i can specify somehow how much of the facts needs to be loaded before firing the rule based on the rule itself? i mean a rule which is aware of the quantity of the facts on which it needs to work on(considering loading 3 facts versus 100 facts)? Thanks a lot in advance for all your inputs and suggestions on this. Thanks Regards Jobin Wilson ___ 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] Query on loading facts dynamically
Thanks W for the quick responseyou are absolutely correct,to reward all the students based on some criteria,all of them should be in WM.But the average of last 3 out of all 75 should become a part of the reward criteria and the challenge as you mentioned would be how to restrict the exam facts to the ones which are relevant for evaluating this criteria. Is there a concept of some kind of a rule pre-processor or an engine which can identify the context of the rule and load the limited facts based on that context? Thanks Regards Jobin Wilson 2010/6/30 Wolfgang Laun wolfgang.l...@gmail.com If you want to reward all students you'll have to have all students in WM, at one time or other. Assuming that you aren't dealing with all the students in China, it doesn't matter much how you do this. Now as for a student's exams, there might be an advantage if you could restrict the set of facts to those that are actually required to compute the average of last 3 out of all. But to fetch just these, you'd have to know some key (e.g., student+course) - but I don't see how you can construct that without having the exam object with all its attributes, especially the date. Regards -W 2010/6/30 jobin wilson jobinwil...@gmail.com Hello List, I have a very basic question about inserting facts into the working memory dynamically.For firing the rules,we should be having all our facts in the working memory.In that case,How will we deal with the situation where the facts that we need for evaluation of a particular rule is dependent on the rule itself (needs to be brought it dynamically)? Say for example say i want to use rule engine to reward all students with average scores for all subjects 75 for the past 3 exams. The facts that i have are the Student objects their Subject wise scores(one to many relation;one student to many exams each exams having many subjects). I want the when condition to be satisfied for all students whose average scores for all subjects for the past 3 exams to be greater than 75 and the consequence to be to just print out the name of the student. In this case,should i be loading all the student objects each of their past exam scores in the whole system to find student objects satisfying this critera? Since i already know that the rule just need the average scores for just the past 3 exams for each student,wouldn't loading the whole facts be inefficient? Is there a way in which i can specify somehow how much of the facts needs to be loaded before firing the rule based on the rule itself? i mean a rule which is aware of the quantity of the facts on which it needs to work on(considering loading 3 facts versus 100 facts)? Thanks a lot in advance for all your inputs and suggestions on this. Thanks Regards Jobin Wilson ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query on performance when adding/removing rules
any suggestions regarding the impact on performance??? DeepakA wrote: We have a set of rules (lets call them old rules) running in our strategy server. A new requirement is that - the client can make calls to the server, at that point new rules need to be loaded in the workin memory (at run time), if the rules get executed then the rules need to be removed from the WorkinMemory (after the consequence section is executed) I would like to know if repeated adding and removing of rules in the working memory will lead to performance issues? i.e. when the new rules are added/removed the old-set-of rules will still be evaluated in the background, will this hamper performance? -- View this message in context: http://old.nabble.com/Query-on-performance-when-adding-removing-rules-tp26475542p26493210.html Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] query or global
what are disadvantages and advantages of the following possibillities to to get access to working memory facts from outside: Is there a reason why you want to use something other than queries? I would suggest to use queries _unless_ you have a definitive requirement that requires something else. Queries are easy and you get constraints for free. Everything else is just work. ;-) If you need to use logicals, you also have to implement an event listener in your facts to track them properly. Cheers --I Am 28.07.2008 um 15:15 schrieb thomas kukofka: Hello again, what are disadvantages and advantages of the following possibillities to to get access to working memory facts from outside: - -uses a query: in drl: query queryname ... end in java code queryResults results = workingMemory.getQueryResults( queryname ); - -use globals that store facts: global java.util.HashMap service rule XY when f: FactX () then ResultFact resultFact = new ResultFact(); service.put(f.getName(), resultFact); insert(resultFact); end kind regards tom ___ 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] Query Problem
Mark, I am certain that this is a bug. In my rules, I was able to make it work where I leave the Open lines on he agenda and he query does in fact pick them up. I wil see if I can create a small test case that demonstrates the problem. What is the link to JIRA so I can log it. Ron On Nov 17, 2007 12:17 PM, Mark Proctor [EMAIL PROTECTED] wrote: Ronald R. DiFrango wrote: All, I have the following query: query Open RTV Lines line : DetailLine(status in (StatusConstants.OPEN, StatusConstants.PARTIALLY_MATCHED)) end And what appears to be happening is it is only picking up those lines that are marked with StatusConstants.PARTIALLY_MATCHED and not those marked with StatusConstants.OPEN. Now here is the rub, if a line gets marked as StatusConstants.OPEN then it gets pulled off the agenda for further processing. Could this be why it is not getting picked up by the query? The agenda thas nothing to do with querries. This should work. If you believe its a bug, then please open a JIRA with a self contained executiable test. Ron -- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] query
As the error message states, you probably forgot to define a package name in your DRL files. []s Edson 2007/9/24, [EMAIL PROTECTED] [EMAIL PROTECTED]: Hi In one of my program i am getting the following erroe message Exception in thread main *org.drools.compiler.PackageBuilder$MissingPackageNameException*: Missing package name for rule package. at org.drools.compiler.PackageBuilder.validatePackageName( *PackageBuilder.java:294*) at org.drools.compiler.PackageBuilder.addPackage( *PackageBuilder.java:226*) at org.drools.compiler.PackageBuilder.addPackageFromDrl( *PackageBuilder.java:160*) at org.drools.compiler.RuleBaseLoader.loadFromReader( *RuleBaseLoader.java:38*) at stockoffer.BusinessLayer.loadRules( *BusinessLayer.java:47*) at stockoffer.BusinessLayer.evaluateStockPurchase( *BusinessLayer.java:60*) at stockoffer.Tempclass.main( *Tempclass.java:22*) So please send me the solution for this error. Thanks. The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli Software Engineer - JBoss Rules Core Developer Office: +55 11 3529-6000 Mobile: +55 11 9287-5646 JBoss, a division of Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] query regarding drl to xml conversion...
Niloy, I suggest you make a drl first and then look at the AST it creates in memory and then make sure that the programmatic descr tree you are making matches that. Mark Niloy Debnath wrote: hi, I'm going to convert a PackageDescr object which has the rules to XML file.I'm trying to convert it into xml using dump method of XmlDumper class. The problem with that is while the rest of the code is fine i cannot get the lhs part. There is no method in fact as far as i know to actually specify the lhs. The setLhs method does not help in this regard. I tried to construct all the parameters ususally specified in the lhs like the ColumnDescr object and FieldBinding object but there is no way to bind these to the PackageDescr object. So the lhs is coming out as null while the rest of the code is fine ...even the rhs.. I am attaching the code and the output again. please go through and advise. thanking you, Niloy Debnath student(comp sc engg) * OUTPUT OF TEST2 :* ?xml version=1.0 encoding=UTF-8? package name=org.drools.examples xmlns=http://drools.org/drools-3.0; xmlns:xs=http://www.w3.org/2001/XMLSchema-instance; xs:schemaLocation=http://drools.org/drools-3.0 drools-3.0.xsd import name=org.drools.examples.Hell.Message / rule name=Hell lhsnull null /lhsrhsSystem.out.println( message );m.setMessage( Goodbye cruel world );m.setStatus( Message.GOODBYE );modify( m );/rhs /rulerule name=Good rule-attribute name=activation-group value=dekhajak / lhsrule-attribute name=activation-group value=dekhajak / rule-attribute name=activation-group value=dekhajak / /lhsrhsSystem.out.println( message ); m.setMessage( message );/rhs /rule /package no visitor implementation for : class org.drools.lang.descr.PatternDescr : [EMAIL PROTECTED] no visitor implementation for : class org.drools.lang.descr.PatternDescr : [EMAIL PROTECTED] no visitor implementation for : class org.drools.lang.descr.PatternDescr : [EMAIL PROTECTED] no visitor implementation for : class org.drools.lang.descr.PatternDescr : [EMAIL PROTECTED] Check out what you're missing if you're not on Yahoo! Messenger http://us.rd.yahoo.com/mail/in/ymessenger/*http://in.messenger.yahoo.com/ ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] query question
no Kevin J. Schmidt wrote: Can a query in a rules file be used in the LHS of another rule? ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users