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


enableDuplicateFiltering is not working
#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


#7

Hello.

I still had no time to look into a feature-request…

I identified a related problem. My workaround is to call repositoryService.deploy() only when my custom logic identified a change in the process definition.

In combination with the deployment aware feature of the jobExecutor

camunda.bpm.job-execution.deployment-aware=true

we now see the following behaviour. After a restart of the application without changes to the model, the JobExecutor won’t pick up jobs for started process-instances.

How do I connect the Engine to my previous deployment?


#8

Hi,
I believe each engine node maintains an in memory register of deployments which feed into the job executor. If you restart a node, you need to trigger re-registration of deployments. (I should point out this is automatic on some typical app server config such as shared engine on Tomcat for example)…

Have a look at the ManagementService.registerDeploymentForJobExecutor(String deploymentId)

regards

Rob


#9

Hi,

Thx. I implemented the following method:

public void redeploy() {
    List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
      .processDefinitionKey("issue-process")
      .list();
    for (ProcessDefinition processDefinition : processDefinitions) {
        managementService.registerDeploymentForJobExecutor(processDefinition.getDeploymentId());
        managementService.registerProcessApplication(processDefinition.getDeploymentId(), processApplication.getReference());
    }
}

Do you know if managementService.registerProcessApplication() includes functionality of registerDeploymentForJobExecutor()? Or dow I have to call both?