Is there any way to add flow element to the process definition on a distributed application

Hi everyone.

What I want to do is that when I come to a task, I’d like to add a task before or after my task.

When the application is a stand-alone one, I may change the process definiton dynamicly by adding UserTasks and SequenceFlows, using runtimeService.createChangeActivityStateBuilder API. It works well.

But when I came to a distributed application, the problem became more difficult. In this issue, I can not get the change on another server.

I’ve made some attempts as follow.

When the issue comes, I copy and deploy a new process definition and change flow nodes, sequence flows on the new definition, witch will be durable in the db. So even on another server I will gain the changes.

But when I use the runtimeService.createChangeActivityStateBuilder API to migarate task from one to another. The engine tells me Cannot find activity * in process definition. I think it is because execution still use the old process definition.

May I change process definition the execution uses at runtime? Or Is there any solution may help me.

Thanks a lot.

Yes, you can execute the SetProcessDefinitionVersionCmd programmatically via the managementService#executeCommand.

I’m not yet following fully - where and when do you call this API? Can you share a bit of the code you’re using to do this?