0

I am trying to make some changes in the runtime of a process using the Fluent API. Is it possible to update the running instance?

Ex: If I want to add a new event between existing events (user Task, Service Task, ...) and run the newly added event. Is there a way to achieve this?

DasSoftware
  • 964
  • 10
  • 19
Harshana
  • 524
  • 3
  • 16

1 Answers1

0

You could do it as follows:

  1. Create the new version of the process and deploy it.
  2. Migrate the process instance to that version.

Minimal code example for step 2:

RuntimeService runtimeService = ..;
ProcessInstance processInstance = ..;

ProcessDefinition oldDefinition = ..;
ProcessDefinition newDefinition = ..;

MigrationPlan migrationPlan = runtimeService
  .createMigrationPlan(oldDefinition.getId(), newDefinition.getId())
  .mapEqualActivities()
  .build();

runtimeSerivce.newMigration(migrationPlan)
  .processInstanceIds(processInstance.getId())
  .execute();

Further reading:

thorben
  • 1,577
  • 8
  • 14
  • Thank you for your answer. I am new to camunda and how can I make the ProcessDefinition from a BpmnModelInstance? – Harshana Nov 06 '18 at 16:36
  • You deploy the model instance via the deployment API and then access the process definition via `RepositoryService#createProcessDefinitionQuery`. `ProcessDefinition` is the deployed thing. – thorben Nov 08 '18 at 16:33