Catch the event of a blocked instance only after a timeout

I have a program where I start several process instances using a cron. For each process instance I have a maximum time, and if the execution time exceeds it, I have to consider it as failure and use some specific methods.
For now what I did was simply to check, once my process instance has finished, if the elapsed time exceeds or not the given maximum time.
But what if my process instance gets blocked for some reason (e.g. server not responding)? I need to catch this event and perform failure operations as soon as the process gets blocked and timeout is exceeded.
How can I catch these two conditions?
I had a look at the FlowableEngineEventType, but there isn’t a PROCESS_BLOCKED/SUSPENDED type of event. But, even if it were, how do I fire it only after a certain amount of time has passed?

Hey,

In order to help you out we would need some more information.

Do your processes have a wait state in them? What kind of tasks are you using? Service Tasks, REST requests or something else? What does “server not responding” mean.

Flowable doesn’t have the concept of a blocked process instance. That is a business concept in your case and can be solved in different ways.

There are Boundary Events that could be to control and model what should happen with an activity or a sub process if the event fires. For your particular case you could use a timer. However, keep in mind that if you don’t have wait states and a process runs into a single transaction then the timer won’t be of much help since it is scheduled only after a wait state is hit.

Cheers,
Filip

Hi,
thank you.
No, I’m not using wait states.
So what happens if I perform a GET request to a server that has a very long response time? The process instance isn’t considered blocked by the engine, but for me it is, since the flow doesn’t go on. And it’s in this case that, after a timeout, I want to stop execution and say “failure”, because the time has exceeded.
And can I use the timer boundary event for this purpose? For what you said I can’t, since it must have a wait state, right? But then how can I handle this without a timer event?

Hey,

If you are using the Flowable HTTP Task then have a look at the documentation to see how you can set the timeouts on it and how you can react on errors there. If you are firing GET requests from your own code you would need to write your own business logic that would throw some kind of BpmnError and you would then handle that in your process.

If you don’t have a wait state then using a timer boundary event will not work for you.

Cheers,
Filip