-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
9432: Support deploying multiple DMN files at once r=saig0 a=remcowesterhoud ## Description <!-- Please explain the changes you made here. --> When deploying multiple DMN resources in a single command users would receive the error ``` io.camunda.zeebe.client.api.command.ClientStatusException: Command 'CREATE' rejected with code 'INVALID_ARGUMENT': Expected to deploy new resources, but encountered the following errors: 'dummy2.dmn': Key DbLong{2251799813685250} in ColumnFamily DMN_DECISION_REQUIREMENTS already exists ``` This error is caused by a bug in Zeebe where we are sending multiple events for the same DRG and decisions. This only occurs when the command contains multiple DMN resources. **Root cause** In the `DmnResourceTransformer` we will transform each resource, so each dmn file. In here we have the method `appendMetadataToDeploymentEvent` . This method will add a `DecisionRequirementsMetadataRecord` to the `DeploymentRecord`. Once the metadata has been added we write the records: ``` private void writeRecords(final DeploymentRecord deployment, final DeploymentResource resource) { for (final DecisionRequirementsMetadataRecord drg : deployment.decisionRequirementsMetadata()) { if (!drg.isDuplicate()) { stateWriter.appendFollowUpEvent( drg.getDecisionRequirementsKey(), DecisionRequirementsIntent.CREATED, new DecisionRequirementsRecord() .setDecisionRequirementsKey(drg.getDecisionRequirementsKey()) .setDecisionRequirementsId(drg.getDecisionRequirementsId()) .setDecisionRequirementsName(drg.getDecisionRequirementsName()) .setDecisionRequirementsVersion(drg.getDecisionRequirementsVersion()) .setNamespace(drg.getNamespace()) .setResourceName(drg.getResourceName()) .setChecksum(drg.getChecksumBuffer()) .setResource(resource.getResourceBuffer())); } } ``` As you can see this method takes the `DeploymentRecord` as a parameter and iterates over all the `DecisionRequirementsMetadataRecords` that have been added. So what happens when we deploy multiple dmns: 1. Send the deploy resource command. We create a new` DeploymentRecord` with an empty list of `DecisionRequirementsMetadataRecords`. 2. We start transforming dmn 1. A new `DecisionRequirementsMetadataRecord` gets appended to the `DeploymentRecord` 3. We write a record for all metadatas in the `DeploymentRecord` . At this point this is only the metadata of dmn 1 4. We start transforming dmn 2. A new `DecisionRequirementsMetadataRecord` gets appended to the `DeploymentRecord` 5. We write a record for all metadatas in the `DeploymentRecord`. At this point this record contains the metadata of both dmn 1 and dmn 2, resulting in a `CREATED` event for dmn 2 containing the metadata keys of dmn 1 ## Related issues <!-- Which issues are closed by this PR or are related --> closes #9337 closes #9115 Related to camunda/zeebe-process-test#357 Co-authored-by: Remco Westerhoud <remco@westerhoud.nl> Co-authored-by: Philipp Ossler <philipp.ossler@gmail.com>
- Loading branch information
Showing
3 changed files
with
143 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
engine/src/test/resources/dmn/decision-table-with-renamed-drg-and-decision.dmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/2.0" id="star-wars" name="Star Wars" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="5.0.0"> | ||
<decision id="sith_or_jedi" name="Jedi or Sith"> | ||
<decisionTable id="DecisionTable_14n3bxx"> | ||
<input id="Input_1" label="Lightsaber color" biodi:width="192"> | ||
<inputExpression id="InputExpression_1" typeRef="string"> | ||
<text>lightsaberColor</text> | ||
</inputExpression> | ||
</input> | ||
<output id="Output_1" label="Jedi or Sith" name="jedi_or_sith" typeRef="string" biodi:width="192"> | ||
<outputValues id="UnaryTests_0hj346a"> | ||
<text>"Jedi","Sith"</text> | ||
</outputValues> | ||
</output> | ||
<rule id="DecisionRule_0zumznl"> | ||
<inputEntry id="UnaryTests_0leuxqi"> | ||
<text>"blue"</text> | ||
</inputEntry> | ||
<outputEntry id="LiteralExpression_0c9vpz8"> | ||
<text>"Jedi"</text> | ||
</outputEntry> | ||
</rule> | ||
<rule id="DecisionRule_1utwb1e"> | ||
<inputEntry id="UnaryTests_1v3sd4m"> | ||
<text>"green"</text> | ||
</inputEntry> | ||
<outputEntry id="LiteralExpression_0tgh8k1"> | ||
<text>"Jedi"</text> | ||
</outputEntry> | ||
</rule> | ||
<rule id="DecisionRule_1bwgcym"> | ||
<inputEntry id="UnaryTests_0n1ewm3"> | ||
<text>"red"</text> | ||
</inputEntry> | ||
<outputEntry id="LiteralExpression_19xnlkw"> | ||
<text>"Sith"</text> | ||
</outputEntry> | ||
</rule> | ||
</decisionTable> | ||
</decision> | ||
<dmndi:DMNDI> | ||
<dmndi:DMNDiagram> | ||
<dmndi:DMNShape dmnElementRef="sith_or_jedi"> | ||
<dc:Bounds height="80" width="180" x="160" y="100" /> | ||
</dmndi:DMNShape> | ||
</dmndi:DMNDiagram> | ||
</dmndi:DMNDI> | ||
</definitions> |