Update Timer using the Java API

Howdy folks,

I see that using the Set Job Due Date Rest call to update a Timer, but I’d like to also be able to do that using the Java API in a Java Delegate

so far i’ve got this:

        EventSubscription theEvent = execution.getProcessEngineServices().getRuntimeService()
        .createEventSubscriptionQuery()
        .processInstanceId(execution.getProcessInstanceId())
        .eventType("timer")
        .eventName(timerName).singleResult();
        

But I’m not sure now how to go about updating the due date… wanna let me know what i can do?

Hi Niall,

you can use the management service to set the due date of a job:

ManagementService managementService = execution.getProcessEngineServices().getManagementService();

Job job = managementService.createJobQuery().processInstanceId(execution.getProcessInstanceId()).timers().singleResult();

managementService.setJobDuedate(job.getId(), newDueDate);

Best regards,
Philipp

Thanks for that Philipp,

Is there also a way to look for a specifically named timer.
The reason i was doing it using the event subscription query is because there are a load of timers but i only want the one which a user has selected.

-Niall

Good point. Using the job query, you can only specify the activity id. But you can combine both query and use the execution id of the EventSubscription for the job query to find the right timer.

-Philipp

1 Like

Perfect, thanks.

Ended up with this:

        EventSubscription theEvent = execution.getProcessEngineServices().getRuntimeService()
                .createEventSubscriptionQuery()
                .processInstanceId(execution.getProcessInstanceId())
                .eventType("timer")
                .eventName(timerName).singleResult();
    

        Job job = execution.getProcessEngineServices().getManagementService().createJobQuery().executionId(theEvent.getExecutionId()).singleResult();
        
        execution.getProcessEngineServices().getManagementService().setJobDuedate(job.getId(), newTimerDate);

Actually… turns out the event subscription doesn’t include timers…
So I’ll just have to stick with the Management Service.

Hi

I need to get a timer without a name or id of them.

Ineed get a time by propertie that i put in a definition like this image.

I am finding for a way for many days :frowning:

Can you help me please?