[rules-users] How to empty the Working memory
Hi, I'm using Drools as a part of a Mule ESB solution and I'm having some problems. Each time i send a message to Drools from the ESB it's content get's asserted as a new fact in the working memory and then there it stays. I would like to only fire the rules on the content of the last message. Is there some way to get a fresh working memory for each time drools is called. I found this post http://drools.46999.n3.nabble.com/How-to-make-the-working-memory-quot-clean-quot-td3790730.html but i didn't understand how or if it was possible to do only using drl files. I've tried passing the drools and kcontext variables to static helper methods and assign a new session each time but then the application just freezes up. Regards //Johan -- View this message in context: http://drools.46999.n3.nabble.com/How-to-empty-the-Working-memory-tp3818693p3818693.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] How to empty the Working memory
Perhaps you should use a rule to retract anything except the initial fact: rule Clear salience -100 when $f: Object( eval( ! $f.getClass().equals( org.drools.reteoo.InitialFactImpl.class) ) ) then retract( $f ); end Alternatively, use the type of an inserted fact, instead of Object and omit the eval. -W On 12/03/2012, Spade87 johan.sp...@gmail.com wrote: Hi, I'm using Drools as a part of a Mule ESB solution and I'm having some problems. Each time i send a message to Drools from the ESB it's content get's asserted as a new fact in the working memory and then there it stays. I would like to only fire the rules on the content of the last message. Is there some way to get a fresh working memory for each time drools is called. I found this post http://drools.46999.n3.nabble.com/How-to-make-the-working-memory-quot-clean-quot-td3790730.html but i didn't understand how or if it was possible to do only using drl files. I've tried passing the drools and kcontext variables to static helper methods and assign a new session each time but then the application just freezes up. Regards //Johan -- View this message in context: http://drools.46999.n3.nabble.com/How-to-empty-the-Working-memory-tp3818693p3818693.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] Persistence in fireUntilHalt() loop
it should work, if it doesn't then it seems like a bug. We are gearing up for release 5.4 now, so might be a while before we can address this. Unless there is a pull request with a suggested fix :) Mark On 08/03/2012 10:32, Alberto R. Galdo wrote: Hi, We're running an application that uses Drools + JBPM 5 + Drools integration our set-up can be seen as: Some rule fires and creates a JBPM process ( a fact gets inserted into drools using kcontext.getKnowledgeRuntime().startProcess(testProcess) ). We have a problem with the persistence of this processes. Persistence is implemented with JPA and JTA. Our application runs with fireUntilHalt() and when a process is launched from the consequence of any of the rules the persistence of the process fails. If the application runs with fireAllRules(), the persistence works like a charm. The error shown is as follow: Exception in thread Thread-5 Exception executing consequence for rule Run Process in com.sample: java.lang.NullPointerException at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029) at org.drools.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1229) at org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:754) at org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:730) at org.drools.command.runtime.rule.FireUntilHaltCommand$1.run(FireUntilHaltCommand.java:50) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.NullPointerException at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.addProcessInstance(JPAProcessInstanceManager.java:44) at org.jbpm.process.instance.AbstractProcessInstanceFactory.createProcessInstance(AbstractProcessInstanceFactory.java:36) at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:182) at org.jbpm.process.instance.ProcessRuntimeImpl.createProcessInstance(ProcessRuntimeImpl.java:154) at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:135) at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:130) at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1074) at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:301) at com.sample.Rule_Run_Process.defaultConsequence(Rule_Run_Process.java:9) at com.sample.Rule_Run_ProcessDefaultConsequenceInvoker.evaluate(Unknown Source) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091) ... 6 more The problem is in this function: public void addProcessInstance(ProcessInstance processInstance) { ProcessInstanceInfo processInstanceInfo = new ProcessInstanceInfo( processInstance, this.kruntime.getEnvironment() ); ProcessPersistenceContext context = ((ProcessPersistenceContextManager) this.kruntime.getEnvironment() .get( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER )) .getProcessPersistenceContext(); // @PrePersist added to ProcessInstanceInfo because of this context.persist( processInstanceInfo ); ((org.jbpm.process.instance.ProcessInstance) processInstance).setId( processInstanceInfo.getId() ); processInstanceInfo.updateLastReadDate(); internalAddProcessInstance(processInstance); } We think after that persist sentence, the entity manager would have to run a flush sentence for the process instance is inserted into database and get the ID. Greets. ___ 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] Class test fails (!= same as ==)
Using 5.3.0.Final, arbitrary facts and the rule shown below: import org.drools.reteoo.InitialFactImpl rule Clear when $f: Object() ### then if( ! ($f instanceof InitialFactImpl) ){ System.out.println( retract a + $f.getClass() ); retract( $f ); } end This retracts my Foo, Bar and Counter facts. Good. $f: Object( class == Foo.class ) ### changed This retracts all of my Foo facts. Excellent. $f: Object( class != Foo.class ) ### changed again This retracts only Foo facts. Bad. -W ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to empty the Working memory
Using that rule worked, sort of... It correctly removes all of the objects in the working memory. The problem is that it clears everything... If you use mule together with drools the drools module will send back whatever you sen to it to mule when there are no more rules fireing. If I delete everything as a last step then I wont get my modified data back. Right now i have one method that takes a WorkingMemory and a collection and inserts everything from the collection in the working memory. *Rule* rule 'addAllFromCollection' when c : MyCollection ( newCollection == true ) then DroolsUtil.insertCollection(drools.workingMemory, c ) end *JavaCode* public static void insertCollection(WorkingMemory workingMemory, Collection collection) { Iterator iterator = collection.iterator(); while (iterator.hasNext()) { workingMemory.insert(iterator.next()); } } Basically what i want to do is write a corresponding function to retract everything that is old *Rule* rule 'retractAllFromCollection' when c : MyCollection ( newCollection == false ) then DroolsUtil.retractCollection(drools.workingMemory, c ) end *JavaCode* public static void retractCollection(WorkingMemory workingMemory, Collection collection) { Iterator iterator = collection.iterator(); while (iterator.hasNext()) { workingMemory.retract(iterator.next()); } } The problem is that the method workingMemory.retract() doesn't take a argument but a FactHandle as an argument but if i try something like *JavaCode* public static void retractCollection(WorkingMemory workingMemory) { Collection collection = workingMemory.getFactHandles(); Iterator iterator = collection.iterator(); while (iterator.hasNext()) { workingMemory.retract(iterator.next()); } } I get a rather strange exception java.lang.UnsupportedOperationException: this is implementedby StatefulKnowledgeImpl at org.drools.reteoo.ReteooWorkingMemory.getFactHandles(ReteooWorkingMemory.java:363) at se.sunstone.ebs.mama.oneqc.drools.DroolsUtil.insertCollection(DroolsUtil.java:21) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) Any thoughts? -- View this message in context: http://drools.46999.n3.nabble.com/How-to-empty-the-Working-memory-tp3818693p3819245.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] How to empty the Working memory
You can save the FactHandle returned from the insert() and retract that. Or you can retrieve the FactHandle via the WorkingMemorEntryPoint method getFactHandle( Object obj ). -W On 12/03/2012, Spade87 johan.sp...@gmail.com wrote: Using that rule worked, sort of... It correctly removes all of the objects in the working memory. The problem is that it clears everything... If you use mule together with drools the drools module will send back whatever you sen to it to mule when there are no more rules fireing. If I delete everything as a last step then I wont get my modified data back. Right now i have one method that takes a WorkingMemory and a collection and inserts everything from the collection in the working memory. *Rule* rule 'addAllFromCollection' when c : MyCollection ( newCollection == true ) then DroolsUtil.insertCollection(drools.workingMemory, c ) end *JavaCode* public static void insertCollection(WorkingMemory workingMemory, Collection collection) { Iterator iterator = collection.iterator(); while (iterator.hasNext()) { workingMemory.insert(iterator.next()); } } Basically what i want to do is write a corresponding function to retract everything that is old *Rule* rule 'retractAllFromCollection' when c : MyCollection ( newCollection == false ) then DroolsUtil.retractCollection(drools.workingMemory, c ) end *JavaCode* public static void retractCollection(WorkingMemory workingMemory, Collection collection) { Iterator iterator = collection.iterator(); while (iterator.hasNext()) { workingMemory.retract(iterator.next()); } } The problem is that the method workingMemory.retract() doesn't take a argument but a FactHandle as an argument but if i try something like *JavaCode* public static void retractCollection(WorkingMemory workingMemory) { Collection collection = workingMemory.getFactHandles(); Iterator iterator = collection.iterator(); while (iterator.hasNext()) { workingMemory.retract(iterator.next()); } } I get a rather strange exception java.lang.UnsupportedOperationException: this is implementedby StatefulKnowledgeImpl at org.drools.reteoo.ReteooWorkingMemory.getFactHandles(ReteooWorkingMemory.java:363) at se.sunstone.ebs.mama.oneqc.drools.DroolsUtil.insertCollection(DroolsUtil.java:21) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) Any thoughts? -- View this message in context: http://drools.46999.n3.nabble.com/How-to-empty-the-Working-memory-tp3818693p3819245.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] How to empty the Working memory
Thank you that worked out nicely =) //Johan 2012/3/12 Wolfgang Laun wolfgang.l...@gmail.com You can save the FactHandle returned from the insert() and retract that. Or you can retrieve the FactHandle via the WorkingMemorEntryPoint method getFactHandle( Object obj ). -W On 12/03/2012, Spade87 johan.sp...@gmail.com wrote: Using that rule worked, sort of... It correctly removes all of the objects in the working memory. The problem is that it clears everything... If you use mule together with drools the drools module will send back whatever you sen to it to mule when there are no more rules fireing. If I delete everything as a last step then I wont get my modified data back. Right now i have one method that takes a WorkingMemory and a collection and inserts everything from the collection in the working memory. *Rule* rule 'addAllFromCollection' when c : MyCollection ( newCollection == true ) then DroolsUtil.insertCollection(drools.workingMemory, c ) end *JavaCode* public static void insertCollection(WorkingMemory workingMemory, Collection collection) { Iterator iterator = collection.iterator(); while (iterator.hasNext()) { workingMemory.insert(iterator.next()); } } Basically what i want to do is write a corresponding function to retract everything that is old *Rule* rule 'retractAllFromCollection' when c : MyCollection ( newCollection == false ) then DroolsUtil.retractCollection(drools.workingMemory, c ) end *JavaCode* public static void retractCollection(WorkingMemory workingMemory, Collection collection) { Iterator iterator = collection.iterator(); while (iterator.hasNext()) { workingMemory.retract(iterator.next()); } } The problem is that the method workingMemory.retract() doesn't take a argument but a FactHandle as an argument but if i try something like *JavaCode* public static void retractCollection(WorkingMemory workingMemory) { Collection collection = workingMemory.getFactHandles(); Iterator iterator = collection.iterator(); while (iterator.hasNext()) { workingMemory.retract(iterator.next()); } } I get a rather strange exception java.lang.UnsupportedOperationException: this is implementedby StatefulKnowledgeImpl at org.drools.reteoo.ReteooWorkingMemory.getFactHandles(ReteooWorkingMemory.java:363) at se.sunstone.ebs.mama.oneqc.drools.DroolsUtil.insertCollection(DroolsUtil.java:21) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) Any thoughts? -- View this message in context: http://drools.46999.n3.nabble.com/How-to-empty-the-Working-memory-tp3818693p3819245.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 -- RF kap. 2 §6 Varje medborgare är gentemot det allmänna skyddad mot påtvingat kroppsligt ingrepp även i annat fall än som avses i 4 och 5 §§. Han är därjämte skyddad mot kroppsvisitation, husrannsakan och liknande intrång samt mot undersökning av brev eller annan förtrolig försändelse och mot hemlig avlyssning eller upptagning av telefonsamtal eller annat förtroligt meddelande. Lag (1976:871). ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] MVEL and nested properties takes longer time to build working memory
Hi, I have rules that uses nested properties. There are more than thousands of such rules. Before using any nested properties, time to build working memory(from decision tables) was pretty fast. After using nested properties, rule compilation time increased by many folds and it is worse in environments where NAS is used instead of SCSI disks. Worst thing is I am not able to profile app using VisualVM as it gives error that 64k limit of instrumented methods exceeded. So took some thread dump using jstack and see that most often thread is doing class loading. This is performed by MVEL classes. On seeing this I used custom class loader in KnowledgeBuilder and printed all loaded classes. I do not see that MVEL is using custom class loader and is directly reading class using some other class loader.This class loading is taking pretty long time when using network disks. Is there any way to speed up rule compilation time when using nested properties.Is there anything like a hint to tell MVEL to load fields of an object directly from that class instead of searching it in entire classpath? I see something like m: in MVELDialectRuntimeData.getParserConfiguration(). Using Drools 5.30 Final and Decision tables. Thanks, Anto ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Setting Non-global Input Variable in ACTION Clause
Is there a way to set the inout variable in the ACTION clause of the decision table, even if that variable is not declared as global nor used in any of the conditions? Thanks! -- View this message in context: http://drools.46999.n3.nabble.com/Setting-Non-global-Input-Variable-in-ACTION-Clause-tp3820353p3820353.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] Setting Non-global Input Variable in ACTION Clause
Is it a typo - inout? Do you mean input or in-out (as in a bi-directional parameter)? You can create new facts in the RHS (ACTION) part of a decision table and insert this into Working Memory. Otherwise, can you please explain what you are trying to achieve a little more? Thanks, On 12 March 2012 20:02, mihajlo mihajlo.jovano...@chase.com wrote: Is there a way to set the inout variable in the ACTION clause of the decision table, even if that variable is not declared as global nor used in any of the conditions? Thanks! -- View this message in context: http://drools.46999.n3.nabble.com/Setting-Non-global-Input-Variable-in-ACTION-Clause-tp3820353p3820353.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] Designer 2.1 install doubts
Hi, I want to try the new version of Designer. So, I've got the designer-2.1-jboss7.war from people.redhat.com/tsurdilo/designer/master. I've renamed to designer.war and deployed into my jboss AS7 that comes with jbpm-5.2.0.Final-installer-full. JbossAS console at http://localhost:9990/console/App.html#deployment-list shows me that designer is enabled but when I try the url http://localhost:8080/designer/ I got a 404 error. Am I missing something ? Btw, must I have guvnor working just to try designer or can I deploy it in a fresh jboss AS instance ? regards, Cristiano ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Designer 2.1 install doubts
Most likely you are missing an empty designer.dodeploy file in your AS installation deploy directory. You can install designer without guvnor, however designer is currently storing processes in guvnor, so as standalone you can only view existing processes, but not create/save new ones. Hope this helps. On 3/12/12 5:47 PM, Cristiano Gavião wrote: Hi, I want to try the new version of Designer. So, I've got the designer-2.1-jboss7.war from people.redhat.com/tsurdilo/designer/master. I've renamed to designer.war and deployed into my jboss AS7 that comes with jbpm-5.2.0.Final-installer-full. JbossAS console at http://localhost:9990/console/App.html#deployment-list shows me that designer is enabled but when I try the url http://localhost:8080/designer/ I got a 404 error. Am I missing something ? Btw, must I have guvnor working just to try designer or can I deploy it in a fresh jboss AS instance ? regards, Cristiano ___ 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] Paralization
Hi, Guys! I want to know is it possible in drools-planner paralization? I mean solving 1 planning problem concurrently in 2 or more jvms -- View this message in context: http://drools.46999.n3.nabble.com/Paralization-tp3821286p3821286.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