Shared process engine with sharding datastores

@devj87, hope all works out :slight_smile:
let me know if you need more help.

Hi @aakhmerov I created two process engine so using the second process engine I get an error starting a process instance as bpmn as not deployed:

ENGINE-16004 Exception while closing command context: no processes deployed with key ā€˜approve-loanā€™: processDefinition is null: org.camunda.bpm.engine.exception.NullValueException: no processes deployed with key ā€˜approve-loanā€™: processDefinition is null

Thanks a lot!

hi @devj87 could you attach your configuration?

Process engine Spring Configuration:

<!-- lookup the process engine from local JNDI -->
<bean name="processEngine" id="processEngine"
    class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName"
        value="java:global/camunda-bpm-platform/process-engine/default" />
</bean>

<!-- lookup the process engine from local JNDI -->
<bean name="processEngine2" id="processEngine2"
    class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName"
        value="java:global/camunda-bpm-platform/process-engine/default2" />
</bean>

processes.xml

<process-application
xmlns="http://www.camunda.org/schema/1.0/ProcessApplication"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<process-archive name="loan-approval">
<process-engine>default</process-engine>
<properties>
  <property name="isDeleteUponUndeploy">false</property>
  <property name="isScanForProcessDefinitions">true</property>
</properties>
</process-archive>
</process-application>

@devj87, did you deploy on both engines? I bet if you check the database, you will see records only on one of them.

yes Iā€™m using two process engine on two different datasource

then if you want to be able to start process on both engines, you have to deploy it on both engines

how can I do?@aakhmerov

@devj87
in your <process-archive name="loan-approval">
you define <process-engine>default</process-engine>

you should define another archive for your second engine too.

already done but I get this error:

Caused by: org.apache.ibatis.exceptions.PersistenceException:
Error querying database.
Cause: java.sql.SQLRecoverableException: Connessione chiusa
The error may exist in org/camunda/bpm/engine/impl/mapping/entity/Job.xml
The error may involve org.camunda.bpm.engine.impl.persistence.entity.JobEntity.selectNextJobsToExecute
The error occurred while executing a query
SQL: select * from ( select a., ROWNUM rnum from ( select RES. from ACT_RU_JOB RES where (RES.RETRIES_ > 0) and (RES.DUEDATE_ is null or RES.DUEDATE_ <= ?) and (RES.LOCK_OWNER_ is null or RES.LOCK_EXP_TIME_ < ?) and RES.SUSPENSION_STATE_ = 1 and (RES.DEPLOYMENT_ID_ is null ) ) a where ROWNUM < ?) where rnum >= ?
Cause: java.sql.SQLRecoverableException: Connessione chiusa

@aakhmerov
this is my processes.xml

     <?xml version="1.0" encoding="UTF-8" ?>
    <process-application
        xmlns="http://www.camunda.org/schema/1.0/ProcessApplication"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
      <process-engine name="default">
        <configuration>org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration</configuration>
      </process-engine>
      
      
      <process-engine name="default2">
        <configuration>org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration</configuration>
      </process-engine>
      
      
      <process-archive name="loan-approval">
        <process-engine>default</process-engine>
        <properties>
          <property name="isDeleteUponUndeploy">false</property>
          <property name="isScanForProcessDefinitions">true</property>
        </properties>
      </process-archive>
      
        <process-archive name="loan-approval">
        <process-engine>default2</process-engine>
        <properties>
          <property name="isDeleteUponUndeploy">false</property>
          <property name="isScanForProcessDefinitions">true</property>
        </properties>
      </process-archive>
    
    </process-application>

@devj87, now you have 2 engines using inmemory database. you have to switch to container managed engines.

Thanks for reply @aakhmerov

Yes Iā€™m using process engine from jndi resources provided by Wildfly so what kind of confguration I have to set rather org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration?

@devj87, please take a look here https://docs.camunda.org/manual/7.5/user-guide/process-engine/multi-tenancy/

<configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration</configuration>

@aakhmerov I tried setting processes.xml as following:

       <process-application
    xmlns="http://www.camunda.org/schema/1.0/ProcessApplication"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <process-engine name="default">
        <configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration</configuration>
      </process-engine>
      
      
      <process-engine name="default2">
        <configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration</configuration>
      </process-engine>


  <process-archive name="loan-approval">
    <process-engine>default</process-engine>
    <properties>
      <property name="isDeleteUponUndeploy">false</property>
      <property name="isScanForProcessDefinitions">true</property>
    </properties>
  </process-archive>
  
    <process-archive name="loan-approval">
    <process-engine>default2</process-engine>
    <properties>
      <property name="isDeleteUponUndeploy">false</property>
      <property name="isScanForProcessDefinitions">true</property>
    </properties>
  </process-archive>

</process-application>

But it doesnā€™t work with same error:
ENGINE-16004 Exception while closing command context: no processes deployed with key ā€˜approve-loanā€™: processDefinition is null: org.camunda.bpm.engine.exception.NullValueException: no processes deployed with key ā€˜approve-loanā€™: processDefinition is null

@devj87, letā€™s try to start following

  <process-engine name="tenant1">
    <job-acquisition>default</job-acquisition>
    <configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration</configuration>
    <datasource>java:jdbc/ProcessEngine</datasource>

    <properties>
      <property name="databaseTablePrefix">TENANT_1.</property>

      <property name="history">full</property>
      <property name="databaseSchemaUpdate">true</property>
      <property name="authorizationEnabled">true</property>
      <property name="useSharedSqlSessionFactory">true</property>
    </properties>
  </process-engine>

  <process-engine name="tenant2">
    <job-acquisition>default</job-acquisition>
    <configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration</configuration>
    <datasource>java:jdbc/ProcessEngine</datasource>

    <properties>
      <property name="databaseTablePrefix">TENANT_2.</property>

      <property name="history">full</property>
      <property name="databaseSchemaUpdate">true</property>
      <property name="authorizationEnabled">true</property>
      <property name="useSharedSqlSessionFactory">true</property>
    </properties>
  </process-engine>

exactly as in example, here java:jdbc/ProcessEngine comes from your container, also donā€™t forget to adjust your

<process-archive name="tenant1-archive">
    <process-engine>tenant1</process-engine>

Not working @aakhmerov this is my processes.xml:

<?xml version="1.0" encoding="UTF-8" ?>

    <process-application
        xmlns="http://www.camunda.org/schema/1.0/ProcessApplication" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
        <process-engine name="default">
            <job-acquisition>default</job-acquisition>
            <configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration
            </configuration>
            <datasource>java:jdbc/ProcessEngine</datasource>
    
            <properties>
                <property name="databaseTablePrefix">TENANT_1.</property>
    
                <property name="history">full</property>
                <property name="databaseSchemaUpdate">true</property>
                <property name="authorizationEnabled">true</property>
                <property name="useSharedSqlSessionFactory">true</property>
            </properties>
        </process-engine>
    
        <process-engine name="default2">
            <job-acquisition>default</job-acquisition>
            <configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration
            </configuration>
            <datasource>java:jdbc/ProcessEngine2</datasource>
    
            <properties>
                <property name="databaseTablePrefix">TENANT_2.</property>
    
                <property name="history">full</property>
                <property name="databaseSchemaUpdate">true</property>
                <property name="authorizationEnabled">true</property>
                <property name="useSharedSqlSessionFactory">true</property>
            </properties>
        </process-engine>
    
    
        <process-archive name="default-loan-approval">
            <process-engine>default</process-engine>
            <properties>
                <property name="isDeleteUponUndeploy">false</property>
                <property name="isScanForProcessDefinitions">true</property>
            </properties>
        </process-archive>
    
        <process-archive name="default2-loan-approval">
            <process-engine>default2</process-engine>
            <properties>
                <property name="isDeleteUponUndeploy">false</property>
                <property name="isScanForProcessDefinitions">true</property>
            </properties>
        </process-archive>
    
    </process-application>

It still return:
no processes deployed with key ā€˜approve-loanā€™: processDefinition is null

;(

@devj87, is deployment present on first process engine?

I think in <process-archive name="default2-loan-approval"> name should be the same, unless you really have separate archive with matching names.

no @aakhmerov I have a folder with bpmn but only a single copy for approve loan archive

@aakhmerov I didnā€™t solved ;( how can I deploy for both sharding process engine?