Spring boot deploy updated definition on runtime

cancel
Showing results for 
Search instead for 
Did you mean: 
coding_nuts
Member II

Spring boot deploy updated definition on runtime

Hello there! I want to re/deploy a new or updated bpmn model with activiti and spring boot at runtime. When i start the application all processes in resources/processes are loaded and updated. But when i change a model the changes are ignored until the next restart. I start the process with an autowired RuntimeService and startProcessInstanceByKey. I also tried to manually deploy the updated model at runtime like this:

ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment().name("demoProcess")
		.addClasspathResource("processes/demo.bpmn20.xml").deploy();

I see the process getting added to the act_ge_bytearray table but when i start a new process the old model gets used and not the new deployed one. How can i tell activiti to activate the new definition? Best case would be that all running processes keep the old version but when i start a new process the latest iteration of that definition gets used. So how can i implement this? 

2 Replies
Moderator
Moderator

Re: Spring boot deploy updated definition on runtime

If you are using Activiti 6 you probably need a tenantId to deploy any resource. I'm not sure that it could solve your problem but I suggest to try the following potential solution.

If you take a look at the unit test included in the APS SDK, based on Activiti 5 Enterprise, you will find a complete example related to a generic Four Eyes workflow:

https://github.com/OpenPj/alfresco-process-services-project-sdk/blob/master/src/test/java/org/alfres...

Below the snippet for deploying a process definition:

repositoryService.createDeployment().addClasspathResource("apps/fourEyes/bpmn-models/4 Eyes Principle-9011.bpmn20.xml")
				.tenantId(tenantId).deploy().getId();

Map<String, Object> processVars = getProcessInitVariables(String.valueOf(user.getId()));
Map<String, Object> taskVars = new HashMap<String, Object>();

ProcessInstance processInstance = runtimeService.startProcessInstanceByKeyAndTenantId("fourEyesPrinciple",
	processVars, tenantId);

As you can see you may need also the tenantId for creating a new instance of your workflow.

Hope this helps.

 

coding_nuts
Member II

Re: Spring boot deploy updated definition on runtime

Thank you for your fast reply! I am not locked on a specific version of Activiti. I have not heard about tenantId before so thank you for this input. But i am not 100% shure if this is what i need. To me it sounds like you can have multiple process definitions with versioning and on top of that you can have multiple tenants. So if understand this correct i have to track all different tenants in my application and create a new one whenever i want to update an existing process. Is this the only way to handel this? Cant i just deploy a new process definition and then update the version so every process now uses the lates version?