[jboss-jira] [JBoss JIRA] (DROOLS-953) Rules from declare window refire after deserialization

Kevin Prendergast (JIRA) issues at jboss.org
Thu Oct 15 22:48:00 EDT 2015


     [ https://issues.jboss.org/browse/DROOLS-953?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kevin Prendergast updated DROOLS-953:
-------------------------------------
    Description: 
Rules using 'from window length' refire incorrectly after session deserialization.

Full story on usage forum.
https://groups.google.com/forum/#!topic/drools-usage/kTHTVXZznxw

In summary...
Insert facts Event#1, Event#2, Event#3 into a stateful, psuedo clock stream session with...

declare window lastEvent
    Event() over window:length(1)
end

rule "Reporting Last Event 1001"
when		
	$e : Event($eventCode : eventCode == "1001") from window lastEvent
then					
	log.info("Reporting Last Event 1001 : " + $e);
end

The rule "Reporting Last Event" will refire after deserialization from disk for Events #1+#2

Demonstrated with the attached reproducer window-demo. Run the JUnit test to get this console output...

 INFO 17:25:40 [org.kev.KnowledgeSession] creating kcontainer
 INFO 17:25:40 [org.drools.compiler.kie.builder.impl.ClasspathKieProject] Found kmodule: file:/C:/Users/Kevin/workspace_luna/window-demo/target/classes/META-INF/kmodule.xml
 INFO 17:25:40 [org.drools.compiler.kie.builder.impl.KieRepositoryImpl] KieModule was added: FileKieModule[releaseId=org.kev:window-demo:0.0.1-SNAPSHOT,file=C:\Users\Kevin\workspace_luna\window-demo\target\classes]
 INFO 17:25:42 [org.kev.KnowledgeSession] no messages from kContainer
 INFO 17:25:42 [org.kev.KnowledgeSession] KieSession sessionDefault is OK {color:#59afe1}INSERTING Event OBJECTS CAUSES RULES TO FIRE NICELY{color}....
 INFO 17:25:42 [org.kev.KnowledgeSession] Reporting Last Event 1001 : Event [eventCode=1001, recordedTime=13-10-15 17:25:39.904]
 INFO 17:25:42 [org.kev.KnowledgeSession] Event Insert : Event [eventCode=1001, recordedTime=13-10-15 17:25:39.904]
 INFO 17:25:42 [org.kev.KnowledgeSession] Rules Fired : 2
 INFO 17:25:42 [org.kev.KnowledgeSession] Reporting Last Event 1001 : Event [eventCode=1001, recordedTime=13-10-15 17:25:40.904]
 INFO 17:25:42 [org.kev.KnowledgeSession] Event Insert : Event [eventCode=1001, recordedTime=13-10-15 17:25:40.904]
 INFO 17:25:42 [org.kev.KnowledgeSession] Rules Fired : 2
 INFO 17:25:42 [org.kev.KnowledgeSession] Reporting Last Event 1001 : Event [eventCode=1001, recordedTime=13-10-15 17:25:41.904]
 INFO 17:25:42 [org.kev.KnowledgeSession] Event Insert : Event [eventCode=1001, recordedTime=13-10-15 17:25:41.904]
 INFO 17:25:42 [org.kev.KnowledgeSession] Rules Fired : 2
 INFO 17:25:42 [org.kev.ReplayTests] Fire All Rules Before Save............  {color:#59afe1}NO MESSAGES HERE. SHOWS NO OUTSTANDING RULES TO FIRE IN SESSION.{color}
 INFO 17:25:42 [org.kev.ReplayTests] Saving Session............ {color:#59afe1}NOW WE SAVE TO DISK{color}
 INFO 17:25:42 [org.kev.KnowledgeSession] Marshalling ksession to disk : C:\Users\Kevin\workspace_luna\window-demo\demo.ks
 INFO 17:25:43 [org.kev.ReplayTests] Restoring Session............ {color:#59afe1}AND HERE'S THE RESTORE OF A NEW SESSION FROM DISK{color}
 INFO 17:25:43 [org.kev.KnowledgeSession] no messages from kContainer
 INFO 17:25:43 [org.kev.KnowledgeSession] KieSession sessionDefault is OK
 INFO 17:25:43 [org.kev.KnowledgeSession] Marshall ksession from disk : C:\Users\Kevin\workspace_luna\window-demo\demo.ks
 INFO 17:25:43 [org.kev.KnowledgeSession] pseudoClock is recovered to :13-10-15 17:25:41.904 ...{color:#59afe1}ALL GOOD SO FAR, BUT NOW I FIRE ALL RULES{color}
 INFO 17:25:43 [org.kev.ReplayTests] Fire All Rules After Restore (1)............{color:#d04437}THESE NEXT MESSAGES ARE UNEXPECTED. IT'S THE FIRST 2 EVENTS THAT I'D ORIGINALLY INSERTED. But, nothing has been inserted since the restore.{color}
 INFO 17:25:43 [org.kev.KnowledgeSession] Reporting Last Event 1001 : Event [eventCode=1001, recordedTime=13-10-15 17:25:39.904]
 INFO 17:25:43 [org.kev.KnowledgeSession] Reporting Last Event 1001 : Event [eventCode=1001, recordedTime=13-10-15 17:25:40.904]
 INFO 17:25:43 [org.kev.ReplayTests] Fire All Rules After Restore (2)............{color:#59afe1}ANOTHER FIRE ALL RULES AND NORMAL BEHAVIOUR RETURNS{color}


Consequence is that RHS fires unexpectedly for facts that have already been handled before serialization.

KP


> Rules from declare window refire after deserialization
> ------------------------------------------------------
>
>                 Key: DROOLS-953
>                 URL: https://issues.jboss.org/browse/DROOLS-953
>             Project: Drools
>          Issue Type: Bug
>          Components: core engine
>    Affects Versions: 6.3.0.Final
>            Reporter: Kevin Prendergast
>            Assignee: Mario Fusco
>            Priority: Minor
>
> Rules using 'from window length' refire incorrectly after session deserialization.
> Full story on usage forum.
> https://groups.google.com/forum/#!topic/drools-usage/kTHTVXZznxw
> In summary...
> Insert facts Event#1, Event#2, Event#3 into a stateful, psuedo clock stream session with...
> declare window lastEvent
>     Event() over window:length(1)
> end
> rule "Reporting Last Event 1001"
> when		
> 	$e : Event($eventCode : eventCode == "1001") from window lastEvent
> then					
> 	log.info("Reporting Last Event 1001 : " + $e);
> end
> The rule "Reporting Last Event" will refire after deserialization from disk for Events #1+#2
> Demonstrated with the attached reproducer window-demo. Run the JUnit test to get this console output...
>  INFO 17:25:40 [org.kev.KnowledgeSession] creating kcontainer
>  INFO 17:25:40 [org.drools.compiler.kie.builder.impl.ClasspathKieProject] Found kmodule: file:/C:/Users/Kevin/workspace_luna/window-demo/target/classes/META-INF/kmodule.xml
>  INFO 17:25:40 [org.drools.compiler.kie.builder.impl.KieRepositoryImpl] KieModule was added: FileKieModule[releaseId=org.kev:window-demo:0.0.1-SNAPSHOT,file=C:\Users\Kevin\workspace_luna\window-demo\target\classes]
>  INFO 17:25:42 [org.kev.KnowledgeSession] no messages from kContainer
>  INFO 17:25:42 [org.kev.KnowledgeSession] KieSession sessionDefault is OK {color:#59afe1}INSERTING Event OBJECTS CAUSES RULES TO FIRE NICELY{color}....
>  INFO 17:25:42 [org.kev.KnowledgeSession] Reporting Last Event 1001 : Event [eventCode=1001, recordedTime=13-10-15 17:25:39.904]
>  INFO 17:25:42 [org.kev.KnowledgeSession] Event Insert : Event [eventCode=1001, recordedTime=13-10-15 17:25:39.904]
>  INFO 17:25:42 [org.kev.KnowledgeSession] Rules Fired : 2
>  INFO 17:25:42 [org.kev.KnowledgeSession] Reporting Last Event 1001 : Event [eventCode=1001, recordedTime=13-10-15 17:25:40.904]
>  INFO 17:25:42 [org.kev.KnowledgeSession] Event Insert : Event [eventCode=1001, recordedTime=13-10-15 17:25:40.904]
>  INFO 17:25:42 [org.kev.KnowledgeSession] Rules Fired : 2
>  INFO 17:25:42 [org.kev.KnowledgeSession] Reporting Last Event 1001 : Event [eventCode=1001, recordedTime=13-10-15 17:25:41.904]
>  INFO 17:25:42 [org.kev.KnowledgeSession] Event Insert : Event [eventCode=1001, recordedTime=13-10-15 17:25:41.904]
>  INFO 17:25:42 [org.kev.KnowledgeSession] Rules Fired : 2
>  INFO 17:25:42 [org.kev.ReplayTests] Fire All Rules Before Save............  {color:#59afe1}NO MESSAGES HERE. SHOWS NO OUTSTANDING RULES TO FIRE IN SESSION.{color}
>  INFO 17:25:42 [org.kev.ReplayTests] Saving Session............ {color:#59afe1}NOW WE SAVE TO DISK{color}
>  INFO 17:25:42 [org.kev.KnowledgeSession] Marshalling ksession to disk : C:\Users\Kevin\workspace_luna\window-demo\demo.ks
>  INFO 17:25:43 [org.kev.ReplayTests] Restoring Session............ {color:#59afe1}AND HERE'S THE RESTORE OF A NEW SESSION FROM DISK{color}
>  INFO 17:25:43 [org.kev.KnowledgeSession] no messages from kContainer
>  INFO 17:25:43 [org.kev.KnowledgeSession] KieSession sessionDefault is OK
>  INFO 17:25:43 [org.kev.KnowledgeSession] Marshall ksession from disk : C:\Users\Kevin\workspace_luna\window-demo\demo.ks
>  INFO 17:25:43 [org.kev.KnowledgeSession] pseudoClock is recovered to :13-10-15 17:25:41.904 ...{color:#59afe1}ALL GOOD SO FAR, BUT NOW I FIRE ALL RULES{color}
>  INFO 17:25:43 [org.kev.ReplayTests] Fire All Rules After Restore (1)............{color:#d04437}THESE NEXT MESSAGES ARE UNEXPECTED. IT'S THE FIRST 2 EVENTS THAT I'D ORIGINALLY INSERTED. But, nothing has been inserted since the restore.{color}
>  INFO 17:25:43 [org.kev.KnowledgeSession] Reporting Last Event 1001 : Event [eventCode=1001, recordedTime=13-10-15 17:25:39.904]
>  INFO 17:25:43 [org.kev.KnowledgeSession] Reporting Last Event 1001 : Event [eventCode=1001, recordedTime=13-10-15 17:25:40.904]
>  INFO 17:25:43 [org.kev.ReplayTests] Fire All Rules After Restore (2)............{color:#59afe1}ANOTHER FIRE ALL RULES AND NORMAL BEHAVIOUR RETURNS{color}
> Consequence is that RHS fires unexpectedly for facts that have already been handled before serialization.
> KP



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list