Duplicate Process Definition


#1

Hi,

after spending some time with Camunda the time has come to ask my first question.

I have an inline ProcessDefinition (BpmnModelInstance) using the Bpmn.createProcess() Builder. On Application startup, I use the RepositoryService to deploy the process definition:

public void deployProcessDefinition() {
  repositoryService
    .createDeployment(processApplication.getReference())
    .enableDuplicateFiltering(true)
    .name("issue-process-name")
    .source("issue-process-source")
    .addModelInstance("issue-process.bpmn", issueProcessModel())
    .deploy();
}

I use enableDuplicateFiltering but nevertheless a new deployment is created every time the application starts. I already set the camundaVersionTag(“1”) in the generated BpmnModelInstance.

How can I prevent a duplicate deployment?


#2

Hi @cachescrubber,

welcome to our forums. :cake:

The passed model is serialised to XML and stored in the database. The duplicate filtering compares the stored with the passed XML and if it is equal, the deployment gets skipped.

How do you make sure that issueProcessMode() is always serialised to an equal XML representation?

Cheers,
Tassilo


#3

Good morning @tasso94

That may be the right question. I generate the BpmnModelInstance using the Java Builder Api. My Source code is not changing at all, so something in the builder is probably generating random ids, for example, which in turn does not pass the equality check. The question would then be: How to make sure to generate the same Xml from a BpmnModelInstance generated by the Java builder unless I change my source code?

best,
Lars


#4

Hi @cachescrubber,

you are absolutely right. The Camunda Model API generates random ids. This is the reason why the process models are considered as different.

What about using an already serialised BPMN XML model (*.bpmn)?

Cheers,
Tassilo


#5

Hi @tasso94,

it is an exercise in how to avoid a xml process model for a simple embedded process.

Why don’t use the camundaVersion attribute to aid in the equality check? This is the workaround I found:

public void deployProcessDefinition() {
  ProcessDefinition deployedDefinition = repositoryService.createProcessDefinitionQuery()
    .processDefinitionKey("issue-process")
    .latestVersion()
    .singleResult();

  BpmnModelInstance bpmnModelInstance = issueProcessModel();
  Process process = bpmnModelInstance.getModelElementById("issue-process");

  if (null == deployedDefinition || deployedDefinition.getVersionTag().compareTo(process.getCamundaVersionTag()) < 0) {
    repositoryService
      .createDeployment()
      .name("issue-process-name")
      .source("issue-process-source")
      .addModelInstance("issue-process.bpmn", issueProcessModel())
      .deploy();
  }
}

#6

Hi @cachescrubber,

please feel free to raise a feature request in our issue tracker [1].

Cheers,
Tassilo

[1] https://app.camunda.com/jira/secure/CreateIssue!default.jspa