[jboss-jira] [JBoss JIRA] (DROOLS-422) Timer based rules don't fire and facts can't expire after session restore

Dushman Elvitigala (JIRA) issues at jboss.org
Sat Sep 20 04:03:02 EDT 2014


    [ https://issues.jboss.org/browse/DROOLS-422?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004473#comment-13004473 ] 

Dushman Elvitigala commented on DROOLS-422:
-------------------------------------------

Hi Davide,

Had a look at code in PhreakTimerNode.java file.  looking at below code segment: 

if ( trigger.hasNextFireTime().getTime() <= timestamp ) {
            // first execution is straight away, so void Scheduling
            if ( log.isTraceEnabled() ) {
                log.trace( "Timer Fire Now {}", leftTuple );
            }

            LeftTuple childLeftTuple = doPropagateChildLeftTuple( sink, trgLeftTuples, stagedLeftTuples, leftTuple, tm );
            if (childLeftTuple.getStagedType() != LeftTuple.NONE) {
                // Flag the newly created childLeftTuple to avoid a reevaluation in case it gets
                // rescheduled before the end of this doNode loop
                childLeftTuple.setObject(Boolean.TRUE);
            }

            trigger.nextFireTime();

            Date nextFireTime = trigger.hasNextFireTime();
            if ( nextFireTime != null && nextFireTime.getTime() <= timestamp ) {
                throw new IllegalStateException( "Trigger.nextFireTime is not increasing" );
            }
        } 

It is evident that program only expects only one miss-fire related to current time.  if the schedule has more than one miss-fires related to current time it throws above exception. In my opinion program should either fire number of missed executions and get scheduled again or it should fire once and advance it's next schedule time with relation to current time. Infact  if I use a much longer repeatable time  I'm able to restore the session correctly.  May be I'm not entirely wrong just shared my thought.

Many Thanks,

Dushman


> Timer based rules don't fire and facts can't expire after session restore
> -------------------------------------------------------------------------
>
>                 Key: DROOLS-422
>                 URL: https://issues.jboss.org/browse/DROOLS-422
>             Project: Drools
>          Issue Type: Bug
>    Affects Versions: 5.5.0.Final
>         Environment: Linux Mint 15
> JBoss AS 5.1
>            Reporter: Nedo Nedic
>            Assignee: Mark Proctor
>         Attachments: drools-mongodb-persistence.zip
>
>
> I have implemented a custom persistence engine for Drools sessions in MongoDB. When session is built for first time, everything works like a charm. I am having some problems when Drools sessions are restored from MongoDB collection. Firstly, interval based rules (for example timer(int: 10s 10s)) don't fire. Some facts that should expire, they just don't expire and remain forever in WM. I attached the source code. When session is built for first time, I use code like this:
> KnowledgeBase kbase = createKBase(getKnowledgeBuilder(rulePackagePath),
> 				config);
> 		if (hasKnowledgeAgent) {
> 			
> 			createKnowledgeAgent(kbase, correlatorId);
> 			
> 			wm = (ReteooStatefulSession) ((KnowledgeBaseImpl) kagent
> 					.getKnowledgeBase()).ruleBase.newStatefulSession(
> 					(SessionConfiguration) ksconf, env);
> 			ksession = new StatefulKnowledgeSessionImpl(wm, kagent
> 					.getKnowledgeBase());
> 			
> 		    stateOutputMarshaller = StateMarshallerFactory.newOutputMarshaller(this, ksession, ksconf);
> 		    stateOutputMarshaller.init();
> 		    ((InternalKnowledgeRuntime) ksession).setEndOperationListener(this);
> 			}
> Then, after every action I update the session in MongoDB collection.
> public void endOperation(InternalKnowledgeRuntime ikr) {
> 		
> 		stateOutputMarshaller.marshall();
> 	}
>  For session restoring, after AS restart I use this code:
> KnowledgeBase kbase = createKBase( getKnowledgeBuilder(rulePackagePath), getKBaseConfig() );
> 			stateInputMarshaller = StateMarshallerFactory.newInputMarshaller( this, kbase, getSessionConf() );
> 			ksession = stateInputMarshaller.unmarshall(correlatorId);
> 			stateOutputMarshaller = StateMarshallerFactory.newOutputMarshaller( this, ksession, getSessionConf() );
> 			
> 			((InternalKnowledgeRuntime)ksession).setEndOperationListener(this);
> 			
> protected static KnowledgeBaseConfiguration getKBaseConfig() {
> 		KnowledgeBaseConfiguration config = KnowledgeBaseFactory
> 				.newKnowledgeBaseConfiguration();
> 		config.setOption(EventProcessingOption.STREAM);
> 		return config;
> 	}
> 	protected static KnowledgeSessionConfiguration getSessionConf() {
> 		KnowledgeSessionConfiguration ksconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
> 	      ksconf.setOption(ClockTypeOption.get("realtime"));
> 		return ksconf;
> 	}
> Any help is appreciated.
> Thanks



--
This message was sent by Atlassian JIRA
(v6.3.1#6329)


More information about the jboss-jira mailing list