JBoss Community

Re: Change a Timer length/period at runtime possible?

created by Ryan Peterson in jBPM - View the full discussion

After getting some help from krisv (thanks again btw!) I think I'm closer, but still not quite able to get this to work.

 

I've tried canceling the old timer (canceling portion works great), but setting up the new timer seems to give issues.


The route I'm trying is:

((TimerNodeInstance) nodeInstance).cancel();

 

// create timerInstance

TimerInstance timerInstance = new TimerInstance();

timerInstance.setDelay(TimeUtils.parseTimeString("5s")); // hard-code to X seconds

timerInstance.setPeriod(0); // hard-code to a period of 0

 

then I register the new timerInstance with the processInstance:

((InternalProcessRuntime)((WorkflowProcessInstance) nodeInstanceContainer).getKnowledgeRuntime().getProcessRuntime()).getTimerManager().registerTimer(timerInstance, (org.jbpm.process.instance.ProcessInstance) nodeInstanceContainer);

 

Lastly I set the timerInstanceId into the TimerNodeInstance:

((TimerNodeInstance) nodeInstance).internalSetTimerId(timerInstance.getId());

 

My trouble is the new timer event never fires.  The old one is definitely canceled, if I set it for a short value (like 5 seconds) it doesn't fire after cancellation.  But it's like the new timer is missing something, as it never fires either no matter what delay value is set. 

 

 

I've also tried modifying the IntervalTrigger time of the original timer, but this change doesn't seem to get picked up either.

 

Both of these I've done while the processInstance.disconnect() was called, and processInstance.reconnect() is called afterwards.

 

Thanks for any help/suggestions!

Reply to this message by going to Community

Start a new discussion in jBPM at Community