Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-14171

Inaccessible tenantId for BpmnParseListener

XMLWordPrintable

    • Icon: Bug Report Bug Report
    • Resolution: Fixed
    • Icon: L3 - Default L3 - Default
    • 7.17.0, 7.17.0-alpha5
    • 7.16.0
    • engine
    • 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):

      1. 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)));
            }
        
      2. 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.

        This is the controller panel for Smart Panels app

              tassilo.weidner Tassilo Weidner
              radist Andrey Marinchuk
              Tassilo Weidner Tassilo Weidner
              Tassilo Weidner Tassilo Weidner
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: