runtimealfrescoactivitibpmnflowable

How can I change Activiti serviceTask delegateExpression's value in runtime?


It happened multiple times, that I change the calss name, which is in the bpmn diagram as a serviceTask's delegateExpression value and then the older processes which aren't finished yet, gets an error because it cannot find the class it is in the delegateExpression.

Im just curious about if I can change the delegateExpression's value in runtime in Activiti? For example, I give a method two parameters: oldName and newName, the method changes the delegateExpression's value in all running processes. Then it won't be a problem anymore if I refactor a used class.

I read the Activiti User Guide and in chapter 3.7, there is ACT_RE_... tables in the database and ACT_RE_PROCDEF stores the used bpmn diagram for the process, but I cannot change it because it will need to rebuild the application to make the changes happen. And I think it isn't the proper way to solve this problem.


Solution

  • Your question is primarily about Activiti but i see a flowable tag, so here is how you can change definition values at runtime for older instances programmatically in flowable

    Flowable offers a DynamicBpmnServicethat can be used to change part of the process definition without needing to redeploy it.

    Here is a sample code snippet that lets you do the same.

    dynamicBpmnService.changeServiceTaskDelegateExpression("id","newExpression");
    

    Where id is the definitionId. You can find references here :

    https://www.flowable.com/open-source/docs/bpmn/ch04-API/#the-process-engine-api-and-services

    https://www.flowable.com/open-source/docs/javadocs/org/flowable/engine/DynamicBpmnService.html