Re: [rules-users] Drools function not working with Javassist facts
Thanks a million Laune, but I'm still getting the same error I created a new project and copied the same code you posted but still the same error. I'm attaching my complete project (without jar files, they can be referenced in .classpath file), please help me kill my desperation to know what I'm doing wrong http://drools.46999.n3.nabble.com/file/n4006075/drools_issue.zip drools_issue.zip -- View this message in context: http://drools.46999.n3.nabble.com/Drools-function-not-working-with-Javassist-facts-tp3996584p4006075.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] Drools function not working with Javassist facts
Does this mean that this problem is due to running this program in Eclipse? I already tried it running in application server as well but it's throwing same error. -- View this message in context: http://drools.46999.n3.nabble.com/Drools-function-not-working-with-Javassist-facts-tp3996584p4006277.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] Drools function not working with Javassist facts
Thanks Laune, I'm using java version 1.6.0_29 -- View this message in context: http://drools.46999.n3.nabble.com/Drools-function-not-working-with-Javassist-facts-tp3996584p4006368.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] Drools function not working with Javassist facts
Thanks Laune, I tried executing it after adding msgCtClass.writeFile(); but it's still throwing the same exception. If you could please share the version of lib files you are using along with the file with the changes? -- View this message in context: http://drools.46999.n3.nabble.com/Drools-function-not-working-with-Javassist-facts-tp3996584p4000536.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] Drools function not working with Javassist facts
Hello, I'm trying to build a rule which accepts the dynamic facts. The dynamic facts are created using the javassist API. The rule works fine when I'm adding a single rule but as soon as I declare any function in the drl file the rule doesn't compile. *Following is the code sample for creating the dynamic facts.* // creating class object final ClassPool pool = ClassPool.getDefault (); CtClass evalClass = pool.makeClass (drools.dynamic.MyDynamicClass); // creating class field final CtField nameField = new CtField (CtClass.intType, Count, evalClass); nameField.setModifiers (Modifier.PRIVATE); evalClass.addField (nameField); // creating getter for the above created field. final CtMethod getter = CtNewMethod.getter (getCount, nameField); evalClass.addMethod (getter); // creating setter for the above created field. final CtMethod setter = CtNewMethod.setter (setCount, nameField); evalClass.addMethod (setter); // finally creating class final Class tempClass = evalClass.toClass (); // creating class object Object obj = tempClass.newInstance() // inserting it in drools droolsSession.insert(obj) *Following is the rule * rule DynamicFactRule dialect mvel when $obj : MyDynamicClass() then $obj.setCount(8); System.out.println(Count set is: +$obj.getCount(8)); end *This rule works fine but when I'm adding a function in drl file then it throws error: * 1) Unable to resolve ObjectType 'MyDynamicClass' 2)Error importing : 'defaultpkg.LogMessage.logMessage' *The function I added is* function void logMessage() { System.out.println(This is log message); } *Following is the environment I'm using* - Drools 5.3.0 - JBoss 6.x - JDK6 I looked at many approaches but I'm confused and out of soln, as none of it is working. I also tried looking at Drools trait but it's going over my head I'll highly appreciate if someone can please suggest what should be the ideal approach to solve it. -- View this message in context: http://drools.46999.n3.nabble.com/Drools-function-not-working-with-Javassist-facts-tp3996584.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] Drools function not working with Javassist facts
Thanks a million for your reply. Yes this is a sample code because the one I'm actually working on is much complex. The actual flow is - create dynamic object and keep it in map - create session and load drl - insert all the dynamically created object in drools session - fire all rules. Yes, when error is thrown the function is declared in same drl in which the rule is. We thought of creating Map instead of Dynamic classes but due to performance constraint we have to use dynamic classes. -- View this message in context: http://drools.46999.n3.nabble.com/Drools-function-not-working-with-Javassist-facts-tp3996584p3996609.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] Drools function not working with Javassist facts
Laune, Thank you a lot for your reply. Here I go explaining the code. *I'm generating dynamic java objects. In this the class file is made once and on each request we make a new instance and insert it in drools session* public Object getFact () throws CannotCompileException, InstantiationException, IllegalAccessException { if (msgClass != null) { return msgClass.newInstance (); } else { final ClassPool pool = ClassPool.getDefault (); CtClass msgCtClass = null; System.out.println (creating new class...); msgCtClass = pool.makeClass (drools.dynamic.Message); final CtField field = new CtField (CtClass.intType, Count, msgCtClass); field.setModifiers (Modifier.PRIVATE); msgCtClass.addField (field); final CtMethod getter = CtNewMethod.getter (getCount, field); msgCtClass.addMethod (getter); final CtMethod setter = CtNewMethod.getter (setCount, field); msgCtClass.addMethod (setter); msgClass = msgCtClass.toClass (); return msgClass.newInstance (); } } *After getting the object I create drools knowledgebase and session* final Object obj = new FactGenerator ().getFact (); final KnowledgeBase knowledgeBase = createKnowledgeBase (); final StatefulKnowledgeSession session = knowledgeBase.newStatefulKnowledgeSession (); try { // final Message msg = new Message (); // msg.setMessage (Test message); // msg.setStatus (0); // session.insert (msg); session.insert (obj); System.out.println (Firing rule...); final int count = session.fireAllRules (); System.out.println (rules count: + count); } finally { session.dispose (); } *Here is the drl file I'm using * import drools.dynamic.Message; rule Hello World dialect mvel when $m : Message() then //System.out.println(count: +$m.getCount()); System.out.println(count: -999); //logMessage(); //System.out.println(Message: +message); retract($m); end function void logMessage() { } --- The above rule works perfect when I'm running it without the function logMessage(). *Below are the jar files I'm using in project * - antlr-2.7.7.jar - antlr-3.3.jar - antlr-runtime-3.3.jar - drools-clips-5.3.0.Final.jar - drools-compiler-5.3.1.Final.jar - drools-core-5.3.0.Final.jar - drools-transformer-jxls-5.1.0.M2.jar - knowledge-api-5.3.0.Final.jar - mvel2-2.1.0.drools14.jar -- View this message in context: http://drools.46999.n3.nabble.com/Drools-function-not-working-with-Javassist-facts-tp3996584p3996964.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] Challenge! Using javassist and drools presents an issue with drl
Folks, I'm also facing this same issue. I tried many things such as creation session object only after I created dynamic classes using javassist CtClass, changing rules, etc. but none of the solution is working. As per my observation the rules are accepting the dynamic class as long as I'm writing the rule as a single function() but the moment I'm splitting the rules in a function I'm getting the following errors: 1) *Unable to resolve ObjectType 'Transac_EE_TDR' * 2) *Error importing : 'defaultpkg.ProcessEE_TPS.processEE_TPS'* Here Transac_EE_TDR is my dynamic class and 'processEE_TPS' is the function name. I will appreciate if someone can help me resolve it. Thanks! BR Ayush -- View this message in context: http://drools.46999.n3.nabble.com/Challenge-Using-javassist-and-drools-presents-an-issue-with-drl-tp763086p3987828.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] Challenge! Using javassist and drools presents an issue with drl
Folks, It's a burning issue for me, I would appreciate if someone can help me solving it. -- View this message in context: http://drools.46999.n3.nabble.com/Challenge-Using-javassist-and-drools-presents-an-issue-with-drl-tp763086p3994285.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] Problem implementing multiple evals
I'm afraid is there no solution to this problem? -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-implementing-multiple-evals-tp2365761p2369105.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] Error using multiple evals
Hi All, When I'm trying to execute multiple evals I'm getting errors. Below is what I'm trying to do MyEvent(prop1=XYZ) over window:time(1m) from entry-point MyStream or (MyEvent() over window:time(1m) from entry-point MyStream and Number($i1 : doubleValue) from accumulate( MyEvent( prop1 == CONNECT, prop2 == 3, eval((prop3 matches (match +getFirstNameRegex()+ Connect)) == true) ) over window:time(1m) from entry-point MyStream, count() ) and eval($i1 getNodeCount()*0.35)) or (MyEvent() over window:time(1m) from entry-point MyStream and Number($i2 : doubleValue) from accumulate( MyEvent( prop1 matches (second|Third{1}_CONNECT, prop2 == 1, eval((prop3 matches (MatchOne|MatchTwo){1}::+getMMSCNameRegex()+, failure)) == true) ) over window:time(1m) from entry-point MyStream, count() ) and eval($i2 getConnectionCount()*0.4)) or (MyEvent() over window:time(1m) from entry-point MyStream and Number($i3 : doubleValue) from accumulate( MyEvent( prop1 matches (E1|E2){1}_CONNECT, prop2 == 3, eval((prop3 matches (REPT (one|five|seven){1}:: +getServerID()+ is down)) == true) ) over window:time(1m) from entry-point MyStream, count() ) and eval($i3 getThirdNodeCount()*0.5)) When I'm trying to execute the above LHS I get org.drools.rule.InvalidPatternException: Required Declarations not bound: '$i1'. Please help it's urgent -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-using-multiple-evals-tp2362605p2362605.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] Error using multiple evals
Hi, I even tried using below approach AlertReceivedEvent() over window:time(1m) from entry-point NotificationStream $I1 : Double() from getIsgNodeCount() Number(doubleValue $I1) from accumulate( AlertReceivedEvent( entity == NPMMS_NE_CONNECT, probableCause == 3, eval((specificProblems matches (REPT ISG NPMMS::Unable to connect to +getPxmmsNameRegex()+ node: PXMMS)) == true) ) over window:time(1m) from entry-point NotificationStream, count() ) But when I'm placing parentheses () around it, it throws exception stating mismatched input '$I1' expecting ')' in rule . I don't want to put these 3 statements (mentioned in the above port) in separate rules. Can anyone please help me solving it? Thanks in advance. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-using-multiple-evals-tp2362605p2363017.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] Error using multiple evals
pls avoid this is just to make my post ACCEPTABLE -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-using-multiple-evals-tp2362605p2363456.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] Error using multiple evals
Hi, I even tried using below approach AlertReceivedEvent() over window:time(1m) from entry-point NotificationStream $I1 : Double() from getIsgNodeCount() Number(doubleValue $I1) from accumulate( AlertReceivedEvent( entity == NPMMS_NE_CONNECT, probableCause == 3, eval((specificProblems matches (REPT ISG NPMMS::Unable to connect to +getPxmmsNameRegex()+ node: PXMMS)) == true) ) over window:time(1m) from entry-point NotificationStream, count() ) But when I'm placing parentheses () around it, it throws exception stating mismatched input '$I1' expecting ')' in rule . I don't want to put these 3 statements (mentioned in the above port) in separate rules. Can anyone please help me solving it? Thanks in advance. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-using-multiple-evals-tp2362605p2365438.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] Problem implementing multiple evals
When I'm trying to execute multiple evals I'm getting errors. Below is what I'm trying to do MyEvent(prop1=XYZ) over window:time(1m) from entry-point MyStream or (MyEvent() over window:time(1m) from entry-point MyStream and Number($i1 : doubleValue) from accumulate( MyEvent( prop1 == CONNECT, prop2 == 3, eval((prop3 matches (match +getFirstNameRegex()+ Connect)) == true) ) over window:time(1m) from entry-point MyStream, count() ) and eval($i1 getNodeCount()*0.35)) or (MyEvent() over window:time(1m) from entry-point MyStream and Number($i2 : doubleValue) from accumulate( MyEvent( prop1 matches (second|Third{1}_CONNECT, prop2 == 1, eval((prop3 matches (MatchOne|MatchTwo){1}::+getMMSCNameRegex()+, failure)) == true) ) over window:time(1m) from entry-point MyStream, count() ) and eval($i2 getConnectionCount()*0.4)) or (MyEvent() over window:time(1m) from entry-point MyStream and Number($i3 : doubleValue) from accumulate( MyEvent( prop1 matches (E1|E2){1}_CONNECT, prop2 == 3, eval((prop3 matches (REPT (one|five|seven){1}:: +getServerID()+ is down)) == true) ) over window:time(1m) from entry-point MyStream, count() ) and eval($i3 getThirdNodeCount()*0.5)) When I'm trying to execute the above LHS I get org.drools.rule.InvalidPatternException: Required Declarations not bound: '$i1'. I even tried using below approach AlertReceivedEvent() over window:time(1m) from entry-point NotificationStream $I1 : Double() from getIsgNodeCount() Number(doubleValue $I1) from accumulate( AlertReceivedEvent( entity == NPMMS_NE_CONNECT, probableCause == 3, eval((specificProblems matches (REPT ISG NPMMS::Unable to connect to +getPxmmsNameRegex()+ node: PXMMS)) == true) ) over window:time(1m) from entry-point NotificationStream, count() ) But when I'm placing parentheses () around it, it throws exception stating mismatched input '$I1' expecting ')' in rule. For now I'd placed these 3 statements in separate rules. Can anyone please help me solving it? Thanks in advance. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-implementing-multiple-evals-tp2365761p2365761.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] how to import rules from a drl to another drl file
Is not there any way using which we can keep rules in say different files and just import them in a single file. This will make the rule management an easy process. Please help me doing this? I don't want to keep all my rules in a single/long file. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/how-to-import-rules-from-a-drl-to-another-drl-file-tp56211p2360526.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] Implementing multiple 'and' 'or' conditions
Hi, I've to write a rule in which there are multiple and, or conditions. Like ( MyEvent(prop = 1) or MyEvent(prop = 2) or MyEvent(prop = 3) ) and MyEvent(prop = 4) and MyEvent(prop = 5) I tried to implement it like $E: ( MyEvent(prop = 1) or MyEvent(prop = 2) or MyEvent(prop = 3) ) MyEvent(prop = 4) MyEvent(prop = 5) but it's throwing error expecting ')'. Can anyone please help me writting this rule? -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Implementing-multiple-and-or-conditions-tp2328123p2328123.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] Implementing multiple 'and' 'or' conditions
Hi, Thanks for your reply. Actually it is lot more complex. Let me present it this way ( (MyEvent(id == 83020402)) or MyEvent() (Number( doubleValue = $numberofISGCDBnodes*.50 ) from accumulate( MyEvent( id == 83020401),count())) or (MyEvent(id == 83030407)) ) and (MyEvent(id == Backlogged source == “SDCS1Site1”)) and (MyEvent(id == MonitorDataUnavailable source == “SDCS1Site1” )) and (MyEvent(id == Backlogged source == “SDCS1”)) and (MyEvent(id == DataUnavailable source == “SDCS2” )) and (MyEvent(id == RepoFail )) and (MyEvent(id == apiRepoFail )) -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Implementing-multiple-and-or-conditions-tp2328123p2328268.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] Implementing multiple 'and' 'or' conditions
Thank you. This worked -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Implementing-multiple-and-or-conditions-tp2328123p2329175.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] Problem implementing dynamic regular expression
Hi, I'm trying to implement regular expression using matches. The regular expression is dynamic and retrieved from a java function. In my first approach I'm tried to call the java function for matches like MyEvent(prop1 matches This event is for+getPropName()+ and is sent to blah blah blah) Now when I try to execute the above expression it gives error as illegal statement (I even tried back-slash to escape it). It also gives error like Expecting ')' instead of '(' . So I declared a function which takes two string parameters and returns me the concatenated one. function String concatenate(String str1, String str2) { return str1+str2; } $matchStr : String() from concatenate(This event is for,getPropName()+ and is sent to blah blah blah) Now when I'm using this variable in my rule it is not getting executed. Please note that there is no problem in regex because when I put the regex as string (i.e. without using any function to retreive it) it works fine. MyEvent(prop1 matches $matchStr) Can anyone please let me know how can I solve it. Thanks in advance. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-implementing-dynamic-regular-expression-tp2319706p2319706.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] Problem implementing dynamic regular expression
Thank you all. I solved it by using eval((myprop matches ...+) == true). I used eval because though without eval it was not throwing any error but it was not running either -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-implementing-dynamic-regular-expression-tp2319706p2326799.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] Problem with or condition
Hi, I'm getting problem while executing rule with or condition. My rule is like MyEvent () from entry-point MyStream Number($objCountForOne : doubleValue) from accumulate( MyEvent(prop1 == One) over window:time(1m) from entry-point MyStream,count()) eval($objCountForOne getMyNodeCount()*0.35) or MyEvent () from entry-point MyStream Number( $objCountForTwo : doubleValue) from accumulate( MyEvent(prop1 == Two), count()) eval($objCountForTwo = getMyConnectionCount()*0.40) The above rule both conditions run well when executed separately but when I merge them using or they don't work well. When I inserted the event for 1st condition it does not gets executed because the last eval line in 2nd condition i.e. eval($objCountForTwo = getMyConnectionCount()*0.40) is false. Now I have to run them like if conditions in java i.e. if(1st == true || 2nd == true) then do my work. Please let me know how can I solve it? Thanks in advance. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-with-or-condition-tp2326849p2326849.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] Problem with or condition
Formatting the rule in above post MyEvent () from entry-point MyStream Number($objCountForOne : doubleValue) from accumulate( MyEvent(prop1 == One) over window:time(1m) from entry-point MyStream,count()) eval($objCountForOne getMyNodeCount()*0.35) or MyEvent () from entry-point MyStream Number( $objCountForTwo : doubleValue) from accumulate( MyEvent(prop1 == Two), count()) eval($objCountForTwo = getMyConnectionCount()*0.40) -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-with-or-condition-tp2326849p2326862.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] Is there any way to find out last two events with some common properties
Hi, I'm also facing the same problem...I've to get latest 3 drools events which can be received at anytime say within 10 minutes. I tried using sliding window wherein the window will rotate on the complete expiry time of drools events. $E1 : MyEvent(prop1 = MyProp) from entry-point MyStream $E2 : MyEvent(prop1 = MyProp, this != $E1) from entry-point MyStream over window:time(10m) Now how can I confirm that $E2 is the latest one I mean 2nd latest after the current one received and also how can I confirm that $E1 is the latest received due to which rules are fired. I think for $E1 I can use window:length(1) but for $E2 I'm not sure . Please suggest -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Is-there-any-way-to-find-out-last-two-events-with-some-common-properties-tp2262553p2270569.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] Removing facts from statefulknowledgeSession's memory
Thanks for replies. Actually what I did now is I declared my fact into drl file and then I'd added an @expires to it. It works fine but now the problem is that for every fact inserted I'd also inserted an event for it. Now as the drl file can be updated by user so say he'd defined expiry time for events as 1m and for facts as 10s in this case since I'm using sliding window for events and based on this event I'm fetching the fact. So now I'll be getting the event but facts will not be available as the 2nd fact came after 20s hence the rule will not be fired. below is the sample rule. declare MyEvent @role(event) @expires( 1m ) end declare MyFact @expires( 10s ) end rule MyCorrelation no-loop true dialect mvel lock-on-active when $E1 : MyEvent( prop1 == 2, $entityA : entity ) over window:time(60s) from entry-point NotificationStream $E2 : MyEvent( this != $E1, prop1 == 1, $entityB : entity ) over window:time(60s) from entry-point NotificationStream $F2 : MyFact(this.entity == $entityB) $F1 : MyFact(this.entity == $entityA) then System.out.println(I'm executed successfully); end Now what I want is that I can define the @expires time at a single location or I can verify the logic of these rules? Also if say I'd defined the @expires for event as 10s while in sliding window I'm using over:time(1m) then also it is not same. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Removing-facts-from-statefulknowledgeSession-s-memory-tp1875795p1887976.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] Removing facts from statefulknowledgeSession's memory
Thanks. Actually I did it in different way what I did is I declared my fact into drl file as declare MyFact and then I'd added an @expires to it. It works fine but now the problem is that for every fact inserted I'd also inserted an event for it. Now as the drl file can be updated by user so say he'd defined expiry time for events as 1m and for facts as 10s in this case since I'm using sliding window for events and based on this event I'm fetching the fact. So now I'll be getting the event but facts will not be available as the 2nd fact came after 20s hence the rule will not be fired. below is the sample rule. declare MyEvent @role(event) @expires( 1m ) end declare MyFact @expires( 10s ) end rule MyCorrelation no-loop true dialect mvel lock-on-active when $E1 : MyEvent( prop1 == 2, $entityA : entity ) over window:time(60s) from entry-point NotificationStream $E2 : MyEvent( this != $E1, prop1 == 1, $entityB : entity ) over window:time(60s) from entry-point NotificationStream $F2 : MyFact(this.entity == $entityB) $F1 : MyFact(this.entity == $entityA) then System.out.println(I'm executed successfully); end Now what I want is that I can define the @expires time at a single location or I can verify the logic of these rules? Also if say I'd defined the @expires for event as 10s while in sliding window I'm using over:time(1m) then also it is not same. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Removing-facts-from-statefulknowledgeSession-s-memory-tp1875795p1887987.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] Removing facts from statefulknowledgeSession's memory
oh yes Thanks this rule will solve my problem. I'm wondering is there any way I can actually verify the business logic of my rules. I'd read about drools-verifier but I've not found enough information for it to be used with drl. I want that in some way I can check the business logic from java classes? -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Removing-facts-from-statefulknowledgeSession-s-memory-tp1875795p1888151.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] Removing facts from statefulknowledgeSession's memory
Ok so drools will not be garbage collecting the facts (as I'm not calling dispose()) and I've to retract them manually. I was wondering cannot there be any way in which I can define expiry time for facts in the same way I declare for events i.e. @expiry -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Removing-facts-from-statefulknowledgeSession-s-memory-tp1875795p1881799.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] Removing facts from statefulknowledgeSession's memory
Hi, In my drools implementation I'm inserting all my facts into working memory and for every fact received I'm also inserting events into notification stream. Now the StatefulKnowledgeSession I'm using is static and it is neither initialized nor disposed after being initialized for first time. My application will run for months without restarting and so the same session will be used without being reinitialized or disposed. Do I have to retract events explicitly or will it handled by drools internally? If not then how can I retract them say after 5 minutes? Also I'm using sliding window and I've not explicitly declared expiry time, for events, in my drl file. Should I define it or will drools remove them after the maximum sliding window time defined in rules? -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Removing-facts-from-statefulknowledgeSession-s-memory-tp1875795p1875795.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] Removing facts from statefulknowledgeSession's memory
Thanks for your reply. Also let me know about facts which are loaded into working memory (Keeping in mind that I'm not calling session.dispose()). Where should I define their expiry time or how should I retract them after 5 minutes? -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Removing-facts-from-statefulknowledgeSession-s-memory-tp1875795p1880471.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] Error Inserting events into drools fusion stream
Thanks for the reply. Can you please elaborate on it? Well we are facing issues keeping same session and entry point alive through out the application. As each event will be received as a new thread in my application so when I'm calling the class which inserts into session and fire-all rules then it's also called as new thread and when called it again initializes the session. I tried to prevent it by not calling session.dispose() and making it static. For the 1st thread it works fine but for the second thread when I insert event into entry-point I get the exception due to concurrent modification. How can I implement it so that the session and entry-point is initialized only once and every new event, which is a new thread, will be inserted into the same entry-point? Also I want that prevoius facts and events should be in drools memory because I'm working on previous alarms as well? -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-Inserting-events-into-drools-fusion-stream-tp1746213p1750771.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] Error Inserting events into drools fusion stream
-- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-Inserting-events-into-drools-fusion-stream-tp1746213p1750917.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] Error Inserting events into drools fusion stream
Thank you for your reply. I think I was heading into the wrong direction. Now when I've synchronized the function which is creating session, session is static and is only called once, and firing the rules it's working fine. I'm planning to use JMS wherein consumer will be syncronized. Is this the right way? But I've following rule rule TwoAlertsFromSameSource no-loop true dialect mvel when $RA : AlertReceivedEvent( severity == 2, $entityA : entity ) over window:time(60s) from entry-point NotificationStream $RB : AlertReceivedEvent( this != $RA, severity == 1, $entityB : entity ) over window:time(60s) from entry-point NotificationStream $alertB : X733Alert(this.entity == $entityB, correlationState != CorrelationStates.ROOT_CAUSE) $alertA : X733Alert(this.entity == $entityA, correlationState != CorrelationStates.SYMPATHETIC) then System.out.println( Running TwoAlertsFromSameSource... ); modify($alertB) { setCorrelationState(Main); } System.out.println(correlation state +$alertB.getCorrelationState()); modify($alertA) { setCorrelationState(Lower); } end In above rules it's unable to modify $alertB. I'm working on it and hoping that this also comes out to be java problem. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-Inserting-events-into-drools-fusion-stream-tp1746213p1750940.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] Error Inserting events into drools fusion stream
Thank you for your reply. I think I was heading into the wrong direction. Now when I've synchronized the function which is creating session, session is static and is only called once, and firing the rules it's working fine. I'm planning to use JMS wherein consumer will be syncronized. Is this the right way? But I've following rule rule TwoAlertsFromSameSource no-loop true dialect mvel when $RA : AlertReceivedEvent( severity == 2, $entityA : entity ) over window:time(60s) from entry-point NotificationStream $RB : AlertReceivedEvent( this != $RA, severity == 1, $entityB : entity ) over window:time(60s) from entry-point NotificationStream $alertB : X733Alert(this.entity == $entityB, correlationState != CorrelationStates.ROOT_CAUSE) $alertA : X733Alert(this.entity == $entityA, correlationState != CorrelationStates.SYMPATHETIC) then System.out.println( Running TwoAlertsFromSameSource... ); modify($alertB) { setCorrelationState(Main); } System.out.println(correlation state +$alertB.getCorrelationState()); modify($alertA) { setCorrelationState(Lower); } end In above rules it's unable to modify $alertB. I'm working on it and hoping that this also comes out to be java problem. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-Inserting-events-into-drools-fusion-stream-tp1746213p1750947.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] Error Inserting events into drools fusion stream
Thanks a lot Wolfgang for your prompt reply. I'm able to move forward now -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-Inserting-events-into-drools-fusion-stream-tp1746213p1751531.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] Error Inserting events into drools fusion stream
Hi All, I'm trying to implement drools fusion into my app. The scenario of my app is as follows: - Facts will be received continuosly. - On receving fact I'm generating a new event and adding it into a new working memory entry point stream. Also I'm adding facts into session coz I'll be updating them. - I need to apply rules on continuous stream of events. - I've not used any camel + spring or pipeline. Are these mandatory to use? For 1st fact everything works fine but when I receive 2nd fact I'm getting Now when I'm trying to get entry point on receive of 2nd alarm I'm getting org.drools.RuntimeDroolsException: Unexpected exception executing action org.drools.reteoo.propagationqueuingnode$propagateact...@9ff411 Caused by: java.util.concurrent.RejectedExecutionException. On debug I found that the above exception is coming when I'm calling session.getWorkingMemoryEntryPoint(MyStream); Can anyone please help me that how should I insert facts and events into working memory? I'd invested ample amount of time searching for this but I'm empty handed. Guys please help this is very urgent for me. Thanks in anticipation -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-Inserting-events-into-drools-fusion-stream-tp1746213p1746213.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