[rules-users] Is it possible to restore StatefulKnowledgeSession?
Hi everyone, I have a ruleflow that calls a ruleflow group. In rhs of one of the rules in the ruleflow group an Exception is thrown. After that, when I insert a new fact into the working memory, the activations for the new fact are not created. To make the session work again, I call .getAgenda().clear(). However, session works incorrectly after that. Is there any other way to 'restore' the StatefulKnowledgeSession, after it has thrown an Exception or should I always create a new session in this case? With best regards, Grigoriy. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools KnowledgeBuilderImpl.add(...) not thread safe???
Wolfgang, Thank you for your idea, but, unfortunately, in our case it is not really suitable, because we'll have to complicate our system very much. Mark, I have created the issue: https://jira.jboss.org/jira/browse/JBRULES-2380 Wbr, Grigoriy ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Mvel and multithreading
Hello, I have a project, that uses Drools 5.0.1. I have a class, called RuleFlowProcessor, that's used to apply some of my rules to the objects. The instances of RuleFlowProcessor with the identical configuration should be used by different threads, and i use following mechanism: I initialize one instance of RuleFlowProcessor, and the threads take copy of this instance, calling the 'clone()' method, which is not synchronized, and in which I just create new instance of RuleFlowProcessor and init it, using the same data. And therefore I get an exception: Exception in thread "Thread-91" [Error: incomplete statement: (possible use of reserved keyword as identifier: )] [Near : {... globals != empt }] ^ [Line: 0, Column: 0] at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:153) at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:44) at org.mvel2.MVEL.eval(MVEL.java:514) although, all the resources (.drl and .rf files) are parsed perfectly, when I use just one thread. In actions of my ruleflow, the dialect: 'mvel' was set by default, if I set dialect to 'java' without modifying any code, the error doesn't occur. The full stacktrace is in attach. I can send the project, that reproduces the problem, if needed. Best regards, Grigoriy Grigoriev. Exception in thread "Thread-91" [Error: incomplete statement: (possible use of reserved keyword as identifier: )] [Near : {... globals != empt }] ^ [Line: 0, Column: 0] at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:153) at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:44) at org.mvel2.MVEL.eval(MVEL.java:514) at org.mvel2.templates.res.IfNode.eval(IfNode.java:61) at org.mvel2.templates.res.TextNode.eval(TextNode.java:46) at org.mvel2.templates.res.TerminalNode.eval(TerminalNode.java:39) at org.mvel2.templates.res.ForEachNode.eval(ForEachNode.java:116) at org.mvel2.templates.res.TextNode.eval(TextNode.java:46) at org.mvel2.templates.res.TerminalNode.eval(TerminalNode.java:39) at org.mvel2.templates.res.TextNode.eval(TextNode.java:46) at org.mvel2.templates.res.IfNode.eval(IfNode.java:62) at org.mvel2.templates.res.TextNode.eval(TextNode.java:46) at org.mvel2.templates.res.ExpressionNode.eval(ExpressionNode.java:53) at org.mvel2.templates.res.TextNode.eval(TextNode.java:46) at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:195) at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:190) at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:180) at org.mvel2.templates.TemplateRuntime.execute(TemplateRuntime.java:169) at org.drools.rule.builder.dialect.java.AbstractJavaRuleBuilder.generatTemplates(AbstractJavaRuleBuilder.java:126) at org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:128) at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:86) at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1159) at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:649) at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:290) at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:488) at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25) at com.myfirm.RuleFlowProcess.init(RuleFlowProcess.java:22) at com.myfirm.RuleFlowProcess.clone(RuleFlowProcess.java:48) at com.myfirm.ThreadTest$CloneThread.run(ThreadTest.java:35) Caused by: java.lang.NullPointerException at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:113) ... 28 more Exception in thread "Thread-32" java.lang.RuntimeException: [-1,-1]: Process 'flow' [sayHello]: Process has no end node. at com.myfirm.RuleFlowProcess.init(RuleFlowProcess.java:33) at com.myfirm.RuleFlowProcess.clone(RuleFlowProcess.java:48) at com.myfirm.ThreadTest$CloneThread.run(ThreadTest.java:35) Exception in thread "Thread-54" [Error: incomplete statement: (possible use of reserved keyword as identifier: )] [Near : {... declarations != empt }] ^ [Line: 0, Column: 0] at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:153) at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:44) at org.mvel2.MVEL.eval(MVEL.java:514) at org.mvel2.templates.res.IfNode.eval(IfNode.java:61) at org.mvel2.templates.res.TextNode.eval(TextNode.java:46) at org.mvel2.templates.res.ExpressionNode.eval(ExpressionNo
[rules-users] Drools ruleflow ForEach node and RuleSet node
Hello, I have a problem with running ruleflow with ForEach node (Drools 5.0.1): ForEach node contains two action nodes(let's say A1 and A2) and one rule set node(let's say R1). I have one object, that is inserted into working memory (let's call it O1), and passed to process instance as a process variable. The collection expression in ForEach node contains collection of parameters. The nodes inside ForEach node are connected as A1 -> R1 -> A2 so for each parameter from the collection the following sequence is performed: in A1 the parameter is set to O1 via setter and update(O1) is called, then the rule set R1 is activated, where some actions are done with the object. And then, in A2, some data, which was changed during 'R1' stage, is extracted from object. The problem is that actions are not called in right consequence. For example, for 4 elements in the collection, the sequence, in which the nodes are triggered is following: A1,A1,A1,A1,R1,A2,A2,A2,A2 instead of A1, R1, A2, A1, R1, A2, A1, R1, A2, A1, R1, A2 The code, used to run drools is: Map variables = new HashMap(); variables.put(OBJECT_VARIABLE_NAME, object); ksession.insert(object); ksession.startProcess(processId, variables); ksession.fireAllRules(); Can you explain such behavior? Thank you. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users