How to prevent the deployment of an unchanged bpmn file?


we would like to deploy a bpmn file in the UTF-8 format by using the repositoryService (not with autoscan, because of internal environment issues). The file is located under src/main/resources/bpmn and has a bunch of executable processes and subprocesses . Currently we are doing it in the following way:

public void deployProcessDefinition(String processDefinitionName, InputStream processDefinitionStream)
    throws WorkflowModelValidationException, IOException {
    String clearTextContent = IOUtils.toString(processDefinitionStream, Charset.defaultCharset().name());
    processDefinitionStream = new ByteArrayInputStream(clearTextContent.getBytes(StandardCharsets.UTF_8));
    BpmnModelInstance bpmnModelInstance = Bpmn.readModelFromStream(processDefinitionStream);
    String resourceName = processDefinitionName.endsWith(".bpmn") ? processDefinitionName
      : processDefinitionName + ".bpmn";
      .addModelInstance(resourceName, bpmnModelInstance).deploy();

and use the method as follows:

InputStream resourceAsStream = this.getClass().getResourceAsStream("/META-INF/bpmn/MyProcess.bpmn");
    this.deployProcessDefinition("RequestTreatmentCollaboration", resourceAsStream);"Process successfully deployed or already exist");

This code is executed everytime when the bean is created (inside the init-method). It works fine, but it is always deploying it, when the bean is starting even if the bpmn file has not changed. I just want to deploy the stuff if the xml has not been changed. Is there a way to check that? Otherwise we will have new versions for not changed process definitions.

I would be grateful for your help.

Best regards,

Hi Andy,



This is not working for me.