Modification + Migration

Hi guys,

I built a simple helper method to execute modification + migration in one step

@Transactional
	public void caseToTaskMigration(String processInstanceId, String sourceActId, String targetActId, String sourceProcDefId, String targetProcDefId){
		this.runtimeService.createProcessInstanceModification(processInstanceId)
				.cancelAllForActivity(sourceActId)
				.execute(true, true);
		
		MigrationPlan migrationPlan = this.runtimeService.createMigrationPlan(sourceProcDefId, targetProcDefId)
				.mapEqualActivities()
				.build();

	this.runtimeService.newMigration(migrationPlan).processInstanceIds(processInstanceId).execute();

	this.runtimeService.createProcessInstanceModification(processInstanceId)
			.startBeforeActivity(targetActId)
			.execute();
}

Unfortunately if I execute this method the migration steps failed with following error.

Process instance contains not migrated incidents: [3479450e-8c22-11e9-a465-005056a17feb]

This incident is assigned to activity I canceled in first modification step.
But it seems that migration does not know about result of modification when it is executed in same transaction.

Is it possible to execute it is same transaction?
If I execute modification via rest it works fine but it would be much more manuals steps

Best regards,

Markus

@Markus process instance seems to be having incidents mentioned before the migration activity. You have to either resolve the incident or migrate the incidents of that process instance.

Since you annotated with @Transactional data will be flushed to the database if everything was executed successful.

@aravindhrs

I canceled the activity (and all incidents plus jobs ) with this modification code.

this.runtimeService.createProcessInstanceModification(processInstanceId)
				.cancelAllForActivity(sourceActId)
				.execute(true, true);

But the migration executed in next line does not know about it.

@Markus i would like to suggest to handle modification and migration in different transaction. During migration activity, it won’t know the context of earlier modification of the same transaction because data is not saved to the database at the point of time.

Have you tested it without @Transactional annotations.

@aravindhrs
I will try to split it in different transactions.
Thanks for feedback.