cancel
Showing results for 
Search instead for 
Did you mean: 

Process suspension and reactivation in activiti 5.9

tushard
Champ in-the-making
Champ in-the-making
Hi,

Activiti 5.9 now supports suspending and resuming process definition and instances.  (Ref: http://www.bpm-guide.de/2012/03/01/activiti-5-9-introduces-more-bpmn-2-0-support/)  I wanted to test this functionality, so I constructed following workflow. 

start –> service_task_1 –> service_task_2 –> end

Both service tasks are marked async = true.  Service_task_1 runs for 100 sec and service_task_2 runs for 10 sec.  Using a standalone process engine, I deployed and started the workflow.  Immediately after starting the workflow, I suspended it by calling RepositoryService.suspendProcessDefinitionByKey(String processDefinitionKey).  This suspended the process by changing the suspendStatus field of the ACT_RE_PROCDEF table. 

I expected the service_task_2 to execute only after reactivating the process.  But, I observed that although the process was suspended, service_task_2 executed immediately after service_task_1 finished.  I wonder if I have correctly understood the concept of process suspension.  Would someone please help me?


Best Regards,

Tushar Deshpande
9 REPLIES 9

trademak
Star Contributor
Star Contributor
Hi,

This sounds like a timing issue.
When you start a new process instance, the async jobs are created immediately and also picked up shortly after that by the job executor.
So when you invoke the suspend action, the jobs are already started and keep running.

Best regards,

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Yep, would be my idea to… But this is only true for async services and not  'timed jobs' like reminders etc… They are suspended afaik.

tushard
Champ in-the-making
Champ in-the-making
Thanks Tijs and Ronald. 

I have a related question.  What happens when an async job is created?  Tijs, you said that the async jobs are created immediately and also picked up shortly after that by the job executor.  Does this mean that upon starting a process having two service tasks marked async = true, the jobExecutor would create two threads, one for each service task?  If true, then is it possible to suspend the execution of the second service task, either using RepositoryService.suspendProcessDefinitionByKey or by any other method?

Best Regards,

Tushar

trademak
Star Contributor
Star Contributor
Hi Tushar,

When you have two service tasks marked with async = true, the Activiti Engine will create two jobs in the database to execute them.
When you have just one job executor, this job executor thread will pick up the outstanding jobs and execute them one by one.
So it's a matter of timing if you can suspend the process definition before the second service task is executed.
But maybe you can tell a bit more about the background of your questions. Why do you need suspension?

Best regards,

tushard
Champ in-the-making
Champ in-the-making
Hi Tijs,

Our processes mainly consists of java service tasks.  One of our requirement states that a user should be able to suspend a running process and resume it later.  The suspend operation would not affect the currently executing service task, but execution of any subsequent service tasks would be suspended.  So, we thought that we can use process suspension and reactivation feature of activiti 5.9.  Would you please give us some suggestions?


Regards,

Tushar Deshpande

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Then don't  make then asyc… Or do I miss something?

yldev
Champ in-the-making
Champ in-the-making
Hi,

We have similar requirements as Tushar's. One of the reasons we made our service tasks async=true is to persist run time state.

It seems runtimeService.suspendProcessInstanceById did put the process instance in suspended state, but the process execution keeps going. We are using Activiti 5.10.

Any suggestions on how to suspend/pause then resume a process instance with async service tasks?

Thanks in advance!
yl

jbarrez
Star Contributor
Star Contributor
So you mean that async jobs still are being executed, even if the instance/process definition is suspended?

That does sound like a bug. Please create a jira for it if that's the case.

ptripathi
Champ in-the-making
Champ in-the-making
jbarrez,
create a JIRA:
http://jira.codehaus.org/browse/ACT-1401

Thanks