1 of 1 people found this helpful
One simple approach could be to use a parameter as a flag (i.e. boolean timeout ) within your process and then simply raise it or not when completing the logic of your process (i.e. right before exiting) or after the timer node. Then at a gateway check the flag's value and decide whether you should raise an exception or not.
In addition a quote from the documentation http://docs.jboss.org/jbpm/v5.1/userguide/ch05.html#sec.timers "The timer is cancelled if the timer node is cancelled (e.g., by completing or aborting the enclosing process instance)." . Actually you don't need to cancel a timer event if it is part of your process logic, instead use your logic inside your process to act accordingly (i.e. as instructed above).
Thank you for the reply. Indeed the approach of boolean parameter is correct. I had thought about that earlier but there is one issue that makes me not use it.
Consider, the process is supposed to take around 2 days to complete (may be because of some human task involved). Now I can not set the timer to anything less than 2 days. In this case, if the process, fortunately completes within an hour or so of starting it, then the whole remaining time is wasted just to wait for timer to expire. Thus, canceling the timer option came to my mind.
About your comment from the user guide, thanks a ton for it. I was under the impression that there would be some special api of xml tags for canceling the timer. But it seems, to cancel timer, the enclosing process needs to be aborted.
However, I have made a few modification myself. I am now using the timer as boundary event. The process to which I wanted to apply timeout, has been declared as subprocess. To this sub-process I have attached timer event as boundary condition. I was expecting that, should the process take more time than the timeout defined in the boundary condition, then timer event will trigger and then I can handle it.
However this is also not working. Currently my process is taking around 10 secinds to complete and i have configured boundary condition with timer of 2 seconds. Still timer is not getting triggered.
I know this is a bit off the track than my initial post, but any help would be greatly appreciated. Thank you.