Remove a process instance from the deployment

Hi Folks,

I have a scenario.

While startup I deploy all my bpmn files as a single process application, this resulting generating the same deployment id for all the processes.
Now I need to remove one specific process from this deployment. Which I cannot do using deleteDeployment since the deployment id is the same for the other processes as well.

How can I undeploy one specific process from this common deployment id?

@Shibin_Thomas2 You can use RepositoryService.deleteProcessDefinition() api to delete specific process definition from the deployment.

Refer the below example:

@Autowired
private RepositoryService repositoryService;

public void deleteProcessDefinitionById(String processDefinitionId) {
	repositoryService.deleteProcessDefinition(processDefinitionId, true, true, true);
}

public void deleteProcessDefinitionByKey(String processDefinitionKey, Optional<Integer> version) {
	ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
			.processDefinitionKey(processDefinitionKey);
	
    processDefinitionQuery = version.isPresent() ? processDefinitionQuery.processDefinitionVersion(version.get())
			: processDefinitionQuery.latestVersion();
	
    ProcessDefinition processDefinition = processDefinitionQuery.singleResult();

	repositoryService.deleteProcessDefinition(processDefinition.getId(), true, true, true);
}

Flag cascade should be set to true if there’s any active process instances are running for the process definition version to be deleted.

Deletes the process definition which belongs to the given process definition id. Cascades the deletion if the cascade is set to true, the custom listener can be skipped if the third parameter is set to true, io mappings can be skipped if the forth parameter is set to true.

Parameters:

processDefinitionId the id, which corresponds to the process definition

cascade if set to true, all process instances (including) history are deleted

skipCustomListeners if true, only the built-in ExecutionListeners are notified with the ExecutionListener.EVENTNAME_END event. Is only used if cascade set to true.

skipIoMappings Specifies whether input/output mappings for tasks should be invoked

1 Like

Yeah, I was trying this out initially. But to remove all the entries I had to try out deployment deletion.
Later I came to know my way of deployment generates an id for every application, so I cannot remove the deployment.
Thank you @aravindhrs, this is working perfectly fine

1 Like