I was using Camunda workflow for one of my usecase. It was working fine with MySQL datasource. But i need a solution or example for the below scenario to achieve this.
Note:
a)I was using “camunda-bpm-spring-boot-starter-rest” and making rest api call to access workflow services.
b)Not using processes.xml file or bpm.xml file to provide datasource details. It was done using java configuration. Like below,
@Configuration(value = “dataSourceConfig”)
public class DataSourceConfig {private static final Logger LOGGER = LoggerFactory.getLogger(DataSourceConfig.class);
@Value(“${ds.dbuser}”)
private String dbUserName;@Value(“${ds.dbpass}”)
private String dbPassword;@Value(“${ds.dburl}”)
private String dbUrl;@Bean(name = “dataSource”)
public DataSource dataSource() {
LOGGER.info(“Inside {} configuration…”, “datasource”);
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
try {
dataSource.setDriver(com.mysql.jdbc.Driver.class.newInstance());
dataSource.setUrl(dbUrl);
dataSource.setUsername(dbUserName);
dataSource.setPassword(dbPassword);
} catch (InstantiationException | IllegalAccessException e) {
LOGGER.info("Exception: {} ", e);
}
return dataSource;
}@Bean(name = “transactionManager”)
public DataSourceTransactionManager transactionManager() {
LOGGER.info(“Inside {} configuration…”, “transactionManager”);
return new DataSourceTransactionManager(dataSource());
}
}
Camunda workflow setup:
a)I have more than one tenant. Let’s say google, microsoft, vmware
b)I’m following schema per tenant and also i have schema’s based on each tenant. I’m using Mysql datasource for all schemas. Schemas are created like this tenant-google, tenant-microsoft, tenant-vmware
c)Camunda workflow itself created as springboot microservice it can run independently and we can scale it up, load balancing , etc.
Observations from camunda doc:
a)One processengine → Multiple Tenant → Table level isolation(having discriminator column)
b)One processengine per tenant → each tenant will have seperate database or seperate schema
Problem:
a)For process engine bootstrapping always dataSource is eagerly initialized
b)Tenant details and related schema are in-place while starting the application.
c)And how can we avoid processengine bootstarpping at application startup. can’t we start process engine lazily based on tenant request?
Expectation/Requirement:
a) Need to introduce new tenant dynamically at any point of time and processengine should connect to that dataSource based on tenant by lazy initalization of datasource(it means processengine should connect with tenant specific schema when tenant specific request is recieved by process engine)
b) One processengine should serve for multiple tenants and schema would be per tenant(it means each tenant will have seperate schema but all tenant requests should be processed by one process engine). Is that possible?
How can we acheive this? If possible share some sample code or example.