-
1. Re: How to cancel a Timer dynamically?
kukeltje Feb 28, 2007 3:24 PM (in response to bsmithjj)Locating it is hard. You have to have some info on the timers, the name of the timer and the token it belongs to. You can then do
executionContext.getJbpmContext().getJobSession().cancelTimersByName(name, token)
If you don't have the name and token, you have to write your own hibernate query. See the implementation in getJobSession. But still you have to base your query on something. The name and token make it unique so it is probably hard to get it in another way -
2. Re: How to cancel a Timer dynamically?
bsmithjj Feb 28, 2007 3:28 PM (in response to bsmithjj)I should have it... I am attempting to do this in execute() method of an ActionHandler. Currently I put the following in (taken from the jBPM source code):
SchedulerService schedulerService = (SchedulerService)Services.getCurrentService( Services.SERVICENAME_SCHEDULER ); schedulerService.cancelTimersByName( UserManagerEscalator.TimerName,exeCtx.getToken() );
Thanks -
3. Re: How to cancel a Timer dynamically?
kukeltje Feb 28, 2007 4:15 PM (in response to bsmithjj)Where do you get that from? the SchedulerService in my (latest) cvs only has
void createTimer(Timer timer); void deleteTimersByName(String timerName, Token token); void deleteTimersByProcessInstance(ProcessInstance processInstance); void close();
but that is the interface... the implementation (e.g. DBSchedulerService) implements delete TimersByName likepublic void deleteTimersByName(String timerName, Token token) { jobSession.cancelTimersByName(timerName, token); }
confusing isn't it ;-)..... I think I'd go for the implementation in CancelTimersAction, but use deleteTimersByName instead of cancelTimersByName ;-) -
4. Re: How to cancel a Timer dynamically?
bsmithjj Mar 5, 2007 9:45 AM (in response to bsmithjj)I've tried many variants of deleting the timer using the API's. I've also tried creating a hibernate query directly and deleting the timer. What I am finding is that I successfully delete the timer, but some other component in jBPM is saving a new copy of the timer on flush of the session.
How do I delete a timer on a task and not have the timer reappear on the task?
Basically, my use case is as follows:
Process enters a task-node where the timer is defined
- during execution of the timer action, I check to see if certain conditions are true
-if these conditions become true, then I want to cancel and delete the timer; the task is still open, it just no longer needs to be timed -
5. Re: How to cancel a Timer dynamically?
bsmithjj Mar 9, 2007 1:33 PM (in response to bsmithjj)Is this not possible?
-
6. Re: How to cancel a Timer dynamically?
michaelok Mar 9, 2007 2:46 PM (in response to bsmithjj)Where do you get that from? the SchedulerService in
That code is from the CancelTimersAction, in both 3.1.1 and 3.1.2 ...
-Signed: another newbie puzzling through timers... ;)