-
Bug Report
-
Resolution: Fixed
-
L3 - Default
-
7.16.0
-
None
We need to create tenantId-sensitive BpmnParseListener. This is required for synchronization with another bpms-engine with external tasks, so we trying to implement some additional checks at deployment time. But at the same camunda instance executes scenarios which does not require additional checks. Also, all new scenarios which requires additional checks will be deployed to the separate tenantId, so it's obvious to use tenantId for turning the checks on.
Environment (Required on creation):
Camunda platform 7.16
Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket):
Trying to obtain tenantId value from the parse listener, but the method ProcessDefinitionEntity.getTenantId returns null.
Steps to reproduce (Required on creation):
- Register the parse listener with logging the tenantId:
private String getTenantId(ScopeImpl scope) { while (scope != null && !(scope instanceof ProcessDefinitionEntity)) { scope = scope.getFlowScope(); } if (scope instanceof ProcessDefinitionEntity) { return ((ProcessDefinitionEntity) scope).getTenantId(); } else { return null; } } @Override public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) { processDefinitions.forEach(p -> LOG.info("deploying the process {} at tenantId {}", p.getId(), getTenantId(p))); }
- Try to deploy any scenario using tenantId = foobar
Observed Behavior (Required on creation):
Logged tenantId is null
Expected behavior (Required on creation):
Logged tenantId is foobar
Root Cause (Required on prioritization):
Method ProcessDefinitionEntity.setTenantId is called whether from AbstractDefinitionDeployer.updateDefinitionByLatestDefinition (initial deployment) or from AbstractDefinitionDeployer.updateDefinitionByPersistedDefinition (existing deployment). Both methods are called indirectly from AbstractDefinitionDeployer.deploy -> AbstractDefinitionDeployer.postProcessDefinitions (after the end of parse).
Solution Ideas (Optional):
Value of tenantId is known at the beginning of the AbstractDefinitionDeployer.deploy, so it could be set-up before calls of BpmnParseListener.
Alternatively additional method could be added to BpmnParseListener to save the DeploymentEntity in ThreadLocal variable to access it's tenantId value during parse process.
Hints (optional):
Currently we can setup our BpmnParseListener which will return the custom BpmnParse which will modify parse process. But this will make a strong dependency on BpmnParse class and could be broken in the future camunda version.