0
votes

I'm using camunda engine on Spring environment, so I'm trying to change process definition for a process instance just like http://docs.camunda.org/latest/guides/user-guide/#process-engine-process-versioning with:

@Transactional
public void migrateProcessInstance(String processInstanceId, int newVersion) {
    SetProcessDefinitionVersionCmd command =
            new SetProcessDefinitionVersionCmd(processInstanceId, newVersion);
    ((ProcessEngineImpl) processEngine)
                    .getProcessEngineConfiguration()
                    .getCommandExecutorTxRequired().execute(command);
}

But it's not working, it's executed without errors but when I see act_hi_procinst and act_ru_task tables nothing has changed. I've seen the SetProcessDefinitionVersionCmd code and I didn't see any call for update like other commands only a few changes for ExecutionEntity and TaskEntity, is that a bug in SetProcessDefinitionVersionCmd or am I doing something wrong?

2

2 Answers

1
votes

This command only updates the current runtime state of the process instance (executions, tasks), such that the process instance continues based on the new process definition.

It does not update historic process instances/tasks even though they may be currently active. One could argue that the process definition id of these entities always refers to the process definition that was valid at the time of their creation and therefore this behavior is expected.

edit: Nevertheless my explanation is not mentioned in the official documentation, probably due to the fact that SetProcessDefinitionVersionCmd is not public API and it is the only case in which the process definition can change. However, the docs you link also do not guarantee anything regarding history, so you are probably expecting something that the command does not provide.

0
votes

This problem sounds similar to an issue I encountered, which should be fixed in the upcoming release 7.2.0

The corresponding bug report is here: https://app.camunda.com/jira/browse/CAM-2523

The fixed SetProcessDefinitionVersionCmd has no other dependencies, you could include a copy of the 7.2.0-SNAPSHOT version inside your project and use that instead.