cancel
Showing results for 
Search instead for 
Did you mean: 

Secure shutting down the engine

martinbauer
Champ in-the-making
Champ in-the-making
Hi,

first of all: i'm a new to activiti - but used to work for years with jbpm.

My question:  How to shut down the engine without destroying executed serviceTasks.
All of my serviceTasks are running very short. So - it would be good that if the engine
is going to be shut down it won't start any new serviceTasks and will wait for all allready started
servicetasks to 'end'.

My suggested solution to this is to provide a global volatile static variable which is set if i want to shut down the system.
Each 'new' serviceTask (java) will wait forever (in the very first line of code) if this variable is set. So no new funtionallity is
run after the 'shutdown' signal was set.

After a little time - i will shut down the system assuming that all allready 'really' running tasks are completed… and all 'new' running tasks are sleeping before any business functions is started …… which wlll be hopefully started after the system is up again… 

Good or bad idea?





3 REPLIES 3

martinbauer
Champ in-the-making
Champ in-the-making
Remark: What happens after a  ProcessEngines.destroy(); 

jbarrez
Star Contributor
Star Contributor
Another option is to make the service task async. The thread pool that executes the async jobs does a graceful shut down when the process engine is closed. Of course a kind of 'barrier' as you describe could also work, but I'm unsure if a volatile property is the best way to do that).

The ProcessEngines.destroy() will close() all process engines it knows of.

martinbauer
Champ in-the-making
Champ in-the-making
Thank you.