timer ( cron:* * 10-18 * * ? ) rule consequences output duplicated

£可爱£侵袭症+ 提交于 2020-01-16 08:03:48

问题


I want to limit the rule run in a specfic time span ,the rule i wrote is as below

rule "Event3"
    timer ( cron:* * 10-18 * * ? )
    no-loop
    when
        $m : EventTest( originNumber == "123", originNumber : originNumber )  from entry-point "ATM Stream"
        or
        $m : EventTest( originNumber == "456",originNumber : originNumber )  from entry-point "ATM Stream"
    then
        System.out.println( $m.getOriginNumber() );
end

when i insert a new fact into engine,every inserted fact before will duplicated triger the rule,how can i forbiden the have existed facts triger the rule?

the output log is below

==>[ObjectInsertedEventImpl: getFactHandle()=5:1:1210939243:1210939243:1:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, getObject()=com.neo.drools.entity.EventTest@482d776b, getKnowledgeRuntime()=KieSession[0], getPropagationContext()=PhreakPropagationContext [entryPoint=EntryPoint::ATM Stream, factHandle=5:1:1210939243:1210939243:1:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, originOffset=-1, propagationNumber=2, rule=null, type=INSERTION]]
==>[ObjectInsertedEventImpl: getFactHandle()=5:2:703555670:703555670:2:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, getObject()=com.neo.drools.entity.EventTest@29ef6856, getKnowledgeRuntime()=KieSession[0], getPropagationContext()=PhreakPropagationContext [entryPoint=EntryPoint::ATM Stream, factHandle=5:2:703555670:703555670:2:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, originOffset=-1, propagationNumber=3, rule=null, type=INSERTION]]
456
123
==>[ObjectInsertedEventImpl: getFactHandle()=5:3:179808568:179808568:3:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, getObject()=com.neo.drools.entity.EventTest@ab7a938, getKnowledgeRuntime()=KieSession[0], getPropagationContext()=PhreakPropagationContext [entryPoint=EntryPoint::ATM Stream, factHandle=5:3:179808568:179808568:3:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, originOffset=-1, propagationNumber=4, rule=null, type=INSERTION]]
123
456
456
==>[ObjectInsertedEventImpl: getFactHandle()=5:4:1068445309:1068445309:4:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, getObject()=com.neo.drools.entity.EventTest@3faf2e7d, getKnowledgeRuntime()=KieSession[0], getPropagationContext()=PhreakPropagationContext [entryPoint=EntryPoint::ATM Stream, factHandle=5:4:1068445309:1068445309:4:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, originOffset=-1, propagationNumber=5, rule=null, type=INSERTION]]
456
123
456
456
==>[ObjectInsertedEventImpl: getFactHandle()=5:5:73698537:73698537:5:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, getObject()=com.neo.drools.entity.EventTest@4648ce9, getKnowledgeRuntime()=KieSession[0], getPropagationContext()=PhreakPropagationContext [entryPoint=EntryPoint::ATM Stream, factHandle=5:5:73698537:73698537:5:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, originOffset=-1, propagationNumber=6, rule=null, type=INSERTION]]
456
123
456
456
456
==>[ObjectInsertedEventImpl: getFactHandle()=5:6:1453062635:1453062635:6:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, getObject()=com.neo.drools.entity.EventTest@569bf9eb, getKnowledgeRuntime()=KieSession[0], getPropagationContext()=PhreakPropagationContext [entryPoint=EntryPoint::ATM Stream, factHandle=5:6:1453062635:1453062635:6:ATM Stream:NON_TRAIT:com.neo.drools.entity.EventTest, originOffset=-1, propagationNumber=7, rule=null, type=INSERTION]]
456
456
456
456
456
123
==>[ObjectInsertedEventImpl: getFactHandle()=[fact 0:7:1632789609:-866637727:7:ATM Stream:NON_TRAIT:java.lang.String:test string aaaa], getObject()=test string aaaa, getKnowledgeRuntime()=KieSession[0], getPropagationContext()=PhreakPropagationContext [entryPoint=EntryPoint::ATM Stream, factHandle=[fact 0:7:1632789609:-866637727:7:ATM Stream:NON_TRAIT:java.lang.String:test string aaaa], originOffset=-1, propagationNumber=8, rule=null, type=INSERTION]]

and i expected log is

123
==========
456
==========
456
==========
456
==========
456

来源:https://stackoverflow.com/questions/59675206/timer-cron-10-18-rule-consequences-output-duplicated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!