Shared process engine with sharding datastores

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?

hi @devj87,

could you publish your code somewhere? on github for instance?

Cheers,
Askar

@aakhmerov ok what kind of files do you need?

I build a “custom” configuration as process engine in sharding environment

So defining pairs of process engine with datasources for example:

engine1 ----> datasource1
engine2 ----> datasource2

all as jndi resource and defined as sring bean as following:

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

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

So I set “running” process engine by our alg so I can fine create tasks in sharding mode but I’can’t start process for a deployment issue 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>

hey @devj87,

just put on the github project files, java classes, config files etc. excluding application server.

Cheers,
Askar.

I’m sorry @aakhmerov I can’to do :frowning:

Hi @devj87,

I am sorry, but I don’t think I can help you without seeing your code and project structure. I think we are not getting common understanding of your problem here and the only realistic way to get it would be to see your project.

Cheers,
Askar

1 Like

Hi @aakhmerov I solved deploying declaring only two archive for each process engine as follow:

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

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

And putting .bpmn under /src/main/resource

:grin:

Best regards