How to prevent the deployment of an unchanged bpmn file?

Hello,

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.close();
    processDefinitionStream = new ByteArrayInputStream(clearTextContent.getBytes(StandardCharsets.UTF_8));
    BpmnModelInstance bpmnModelInstance = Bpmn.readModelFromStream(processDefinitionStream);
    Bpmn.validateModel(bpmnModelInstance);
    String resourceName = processDefinitionName.endsWith(".bpmn") ? processDefinitionName
      : processDefinitionName + ".bpmn";
    processEngine.getRepositoryService().createDeployment().name(processDefinitionName)
      .addModelInstance(resourceName, bpmnModelInstance).deploy();
  }

and use the method as follows:

InputStream resourceAsStream = this.getClass().getResourceAsStream("/META-INF/bpmn/MyProcess.bpmn");
    this.deployProcessDefinition("RequestTreatmentCollaboration", resourceAsStream);
    log.info("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,
Andy

Hi Andy,

See https://docs.camunda.org/javadoc/camunda-bpm-platform/7.7/org/camunda/bpm/engine/repository/DeploymentBuilder.html#enableDuplicateFiltering(boolean)

Cheers,
Thorben

This is not working for me.