cancel
Showing results for 
Search instead for 
Did you mean: 

Provision of pause/resume and retry functionality as part of process engine

debadarsini
Champ in-the-making
Champ in-the-making
Hi,

We wanted this functionality for our project.

We had to create a custom signalable activity behaviour implementation to provide resume/pause and retry functionalities.

Can this be included as part of the activiti engine itself?

If required me and my team can contribute.

Let us know your thoughts.

Regards,
Debadarsini
maryrani ( Mary Rani)
ak1801(Akshit)
1 ACCEPTED ANSWER

cjose
Elite Collaborator
Elite Collaborator

A little late to the party here..how different in the pause/resume requirement to the already existing suspend/activate function in the activiti engine? Some references to suspend/activate feature is given below.

https://www.activiti.org/userguide/#api.services.suspend
https://www.activiti.org/userguide/#_suspend_a_process_definition
https://www.activiti.org/userguide/#_activate_or_suspend_a_process_instance

View answer in original post

9 REPLIES 9

anilmann
Confirmed Champ
Confirmed Champ
Hi Debadarshini,

I am too trying to implement same stuff. It will be of great help if you can share the code.

Thanks in Advance.

spalloin
Champ in-the-making
Champ in-the-making

Hi all,

we also want to add this functionality to our project. Our use case is to retry a failed service task without restarting the whole workflow. Moreover this functionality shall be accessible via a REST call.

I've made some research and found that this feature has already been asked quite a few time.

How to implement restart/pause/resume in Activiti 

activiti-unit-test-grasshopper/MyUnitTest.java at master · martin-grofcik/activiti-unit-test-grassho... 

The last link gives some unit test and code for a 'RestartInstanceActivitiCommand'. However I'm not able to integrate it to our use case.

The current solution I'm investigating is by using an error boundary event to catch the service task failure. This error boundary event is linked to a receive task waiting for a signal to restart the service task, as the following figure illustrate :

This diagram work well, as we are able to successfully retry the service task when it fail, but the workflow does not seems to reach the end event when the service task is finally successful. The process instance isn't ended.

Any hint or advice for another strategy in order to implement this feature will be greatly appreciated.

Best Regards.

thuynh
Star Contributor
Star Contributor

Hi Sylvain,

I've tried your pattern in my sandbox and was successfully able to reach the end of the instance.
Inline image 2
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.activiti.designer.test.PaymentProcessTest
Dec 16, 2016 2:05:40 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [activiti.cfg.xml]
Dec 16, 2016 2:05:43 PM org.activiti.engine.impl.db.DbSqlSession executeSchemaResource
INFO: performing create on engine with resource org/activiti/db/create/activiti.h2.create.engine.sql
Dec 16, 2016 2:05:43 PM org.activiti.engine.impl.db.DbSqlSession executeSchemaResource
INFO: performing create on history with resource org/activiti/db/create/activiti.h2.create.history.sql
Dec 16, 2016 2:05:43 PM org.activiti.engine.impl.db.DbSqlSession executeSchemaResource
INFO: performing create on identity with resource org/activiti/db/create/activiti.h2.create.identity.sql
Dec 16, 2016 2:05:43 PM org.activiti.engine.impl.ProcessEngineImpl <init>
INFO: ProcessEngine default created
Dec 16, 2016 2:05:43 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource paymentProcess.bpmn20.xml
Dec 16, 2016 2:05:50 PM java.util.logging.LogManager$RootLogger log
INFO: Execute validate service task for execution id 12
Dec 16, 2016 2:05:50 PM java.util.logging.LogManager$RootLogger log
INFO: received isbn 
Dec 16, 2016 2:05:50 PM java.util.logging.LogManager$RootLogger log
SEVERE: There is BPMN exception here. Error is: org.activiti.engine.delegate.BpmnError:  (errorCode='isbnisblank')
id 5 paymentProcess:1:4
Dec 16, 2016 2:05:50 PM java.util.logging.LogManager$RootLogger log
INFO: Process instance started: id: 5 paymentProcess:1:4
Dec 16, 2016 2:05:50 PM java.util.logging.LogManager$RootLogger log
INFO: Process execution:  id: 5 and current activity id= null
Dec 16, 2016 2:05:50 PM java.util.logging.LogManager$RootLogger log
INFO: Process execution:  id: 9 and current activity id= receivetask1
Dec 16, 2016 2:05:50 PM java.util.logging.LogManager$RootLogger log
INFO: Target execution id:9
Dec 16, 2016 2:05:50 PM java.util.logging.LogManager$RootLogger log
INFO: Execute validate service task for execution id 17
Dec 16, 2016 2:05:50 PM java.util.logging.LogManager$RootLogger log
INFO: received isbn 456
Dec 16, 2016 2:05:50 PM java.util.logging.LogManager$RootLogger log
INFO: Running processes: 0
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.993 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.403s
[INFO] Finished at: Fri Dec 16 14:05:50 ICT 2016
[INFO] Final Memory: 10M/167M
[INFO] ------------------------------------------------------------------------
So the unit test execution is as follows:
1. Start the instance with 'isbn' variable blank
2. Instance gets to Service Task 'Validate" which is defined in a Java class, which will do some validation logic
3. Service task will fail on purpose and throw a BPMNError exception
4. Error intermediate event will catch the exception and flow to 'Wait' receive task
5. Update the business logic so next time the service task 'validation' is executed, no error should be thrown
6. Signal the flow to continue 
7. Successfully end process instance
So this proves that your model should be working fine. You said then the service task was passed successfully but the instance wasn't ended. Could you debug where was the process execution at that point. You can double check the execution by running a query such as follows:
executions = runtimeService.createExecutionQuery()
.processInstanceId(processInstance.getId())
.list();
for (Execution execution : executions) {
rootLogger.info("Process execution: " + " id: " + execution.getId() + " and current activity id= "
+ execution.getActivityId());
}
 Thanks,
 Thong Huynh

thuynh
Star Contributor
Star Contributor
Hi Debadarsini,
 
In order to contribute your behavior class to the activiti engine, you can open a Jira ticket at https://activiti.atlassian.net. You can create a pull request to contribute your solution.
 
Thank you very much for the contribution.
Thong Huynh

ak1801
Champ in-the-making
Champ in-the-making

Hi Thong,

Thanks for the reply. We have created a Jira ticket for this issue, link - https://activiti.atlassian.net/browse/ACT-4249 

Currently, it is not assigned to anyone. Please assign the bug to us so that we can start contributing.

We are a team of 3.

- debadarsini

- mary.rani

- ak1801

Also, please provide link to Activiti Development guide & Guide for Contributions (if any) for our reference.

Best Regards,

Akshit.

thuynh
Star Contributor
Star Contributor

Hi Ak,

I am not an Alfresco employee so I can't really assign you to anything. I have seen best practice guideline for being a contributor for Activiti. I'd recommend you looking at these resources:

- Become Activiti contributor: Activiti FAQ 

- Jira issue unit test: How to write a unit test when creating an Activiti Jira issue | Small steps with big feet 

Hope that helps

Thanks,

Thong Huynh

ak1801
Champ in-the-making
Champ in-the-making

Hi Thong,

No problem. We'll follow the resources which your shared.

Thanks again for the help.

Regards,

akshit mahajan

cjose
Elite Collaborator
Elite Collaborator

A little late to the party here..how different in the pause/resume requirement to the already existing suspend/activate function in the activiti engine? Some references to suspend/activate feature is given below.

https://www.activiti.org/userguide/#api.services.suspend
https://www.activiti.org/userguide/#_suspend_a_process_definition
https://www.activiti.org/userguide/#_activate_or_suspend_a_process_instance

sarveshmvm
Confirmed Champ
Confirmed Champ

Hello Debadarshini,

Where can I see the implementation of the above. Can yoy please let me know the path as I have some requirement similar to this. For now we are using Boundary events as workaround