How can I associate a signal event to a timer job in order to cancel it

Hello,

Could someone help me, please.

My question seems to be quite simple but I couldn’t find the answer. :slight_smile:

  • How can I register a timer job to subscribe a signal event ?

I’m just trying to cancel a timer job using a signal event as shown in the picture below:
wf

When getting the list of signal event subscription, my timer job is not there.


ProcessInstance processInstance = getProcessInstance(processId);
if (processInstance != null) {
List executions = runtimeService.createExecutionQuery().signalEventSubscriptionName(signalId).processInstanceId(processInstance.getId()).list();

            for (Execution execution : executions) {
                runtimeService.signalEventReceived(signalId, execution.getId());
            }

For some reason the executions is empty.

But we are able to get the timer job in running timer jobs list below:

 List<Job> currentRunningTimerJobList =
             processEngine.getProcess().getManagementService().createTimerJobQuery().timers().processInstanceId(processInstance.getProcessInstanceId())
             .list();

Thank you and Best Regards
Hamilton R.

I imagine your use case is something like: “Wait for a signal until a timeout occurs”

Flowable has the Event Based Gateway for just that use case. Every signal flow leaving the gateway must connect to an intermediate event of some sort. The process only follows the path where the event occurred.

If this is not your use case, can you describe it in more detail?

Hello wwitt thank you very much for your answer.
I don’t think this can help in my case.
Let me try to explain it a little better based on my previous picture.
My process reach an intermediate timer T1 and will stay there until the timer date is reached and go to user task “DA”.
In between, (before reaching the timer date), there is a external busyness event that say that I don’t need to wait for this timer anymore, so I need to cancel it and take another flow to the user task “AA” instead of waiting for the timer to expire.
How can I cancel my timer job which is running and force the flow to “AA” instead of “DA”?

This essentially does just that:
image

This flow will execute DA if a 3 month timer expires or AA if the DoNotWait signal is received (essentially cancelling the timer). Only one of the paths will get executed based on which event occurs first.

Humm ok…sounds good to me. I Will try this.
Thank you very much.

Hello, @wwitt

I am in the same dev team as @Hamilton, i’ve just tried to do what you have suggested and it worked perfectly!

Thanks so much for the help! :slight_smile:

Hello @wwitt,

Once again thank you very much for your support. :slight_smile:

Hello, @wwitt ,

The first problem we’ve solved, but now we’ve another one.

At the first time everything works perfectly, the signal is sent, the timer is deleted but when we launch the timer another time and send the same signal another time, the list of executions of the code below is empty.

ProcessInstance processInstance = getProcessInstance(processId);
		if (processInstance != null) {
			List<Execution> executions = runtimeService.createExecutionQuery().signalEventSubscriptionName(signalId).processInstanceId(processInstance.getId()).list();

			for (Execution execution : executions) {
				runtimeService.signalEventReceived(signalId, execution.getId());
			}

Do you have a clue why this is happening?

We need to finish the timer again, but we cannot manage to do that, once the list of executions is empty.

Thanks.

I think we need a bigger view of your process and what you are trying to accomplish. How are you launching the timer another time? How is the timer configured?

Hi, @wwitt,
Thanks for the quick reply, i’ve already understanded what was wrong :slight_smile:

Once again, thank you!