Process defined using Model API - every-time deployment, even with no changes

I use Model API to define process and I faced with problem that process is deployed every time, even if its definition was not changed.

As I can see resolving resources to deploy, also due to their potential changes is implemented here:
org.camunda.bpm.engine.impl.cmd.DeployCmd#resolveResourcesToDeploy

This method use also another method
org.camunda.bpm.engine.impl.cmd.DeployCmd#resourcesDiffer
which compares two XML process definitions - existing, and new (potentially the same as existing). But when these XMLs are generated by Model API, all element ids are generated on the fly and are different for every single deploy of the same process definition - e.g.

<incoming>sequenceFlow_5727473e-da38-4075-a0ac-2167d2b60869</incoming>
<bpmndi:BPMNDiagram id="BPMNDiagram_316dd423-39b4-4eb3-a4aa-2dde2c43152a">
<bpmndi:BPMNShape bpmnElement="..." id="BPMNShape_99f63448-ae44-4d4a-a315-f42d253188a9">

Hence, every generated process definition XML by Model API is different from previous and is deployed every time.

Deployment realisation in my code:

repositoryService
    .createDeployment()
    .name("shop-deployment")
    .source("shop")
    .tenantId("shop")
    .enableDuplicateFiltering(true)
    .addModelInstance("shop.bpmn", modelInstance)
    .deploy()

Does anyone know how to handle it?

Camunda v. 7.11

@fattdamon You need to set deployChangedOnly=true

I think I set up it already by calling

.enableDuplicateFiltering(true)

from sources:

  /**
   * Check the resources for duplicates in the set of previous deployments with
   * same deployment source. If no resources have changed in this deployment,
   * its contained resources are not deployed at all. For further configuration,
   * use the parameter <code>deployChangedOnly</code>.
   *
   * @param deployChangedOnly determines whether only those resources should be
   * deployed that have changed from the previous versions of the deployment.
   * If false, all of the resources are re-deployed if any resource differs.
   */
  DeploymentBuilder enableDuplicateFiltering(boolean deployChangedOnly);

Hi @fattdamon,

you can set the element ids explicitly to a fixed value. Have a look in the example code here: https://docs.camunda.org/manual/7.11/user-guide/model-api/bpmn-model-api/create-a-model/, especially in the createElementcreateElement(BpmnModelElementInstance parentElement, String id, Class<T> elementClass) method.

This would generate an identical model everytime and it will be filtered as duplicate.

Hope this helps, Ingo

1 Like