Hi,
are there any examples of how to deploy processes for multiple tenants (Shared-Engine / Shared-Schema) using the auto deploy provided by the spring boot starter?
At this moment I had to do de following for my POC:
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class Application {
public static void main(String args[]) {
SpringApplication.run(Application.class, args);
}
@Bean
public CommandLineRunner init(final RepositoryService repositoryService, final RuntimeService runtimeService,
final TaskService taskService) {
return new CommandLineRunner() {
@Override
public void run(String... strings) throws Exception {
repositoryService.createDeployment().addClasspathResource("processes/article-workflow.bpmn20.xml")
.tenantId(BPMCustomConfiguration.TENANT_01).deploy();
repositoryService.createDeployment().addClasspathResource("processes/article-workflow.bpmn20.xml")
.tenantId(BPMCustomConfiguration.TENANT_02).deploy();
}
};
}
}
Additionally, are there detailed examples for the “Shared-Engine / Multi-Schema” mode using MultiSchemaMultiTenantProcessEngineConfiguration other than the published in this article https://blog.flowable.org/2018/09/11/multitenancy-in-flowable/ ?
The code example you have is correct: when a tenantId is set on the deployment, all derived process definitions will be part of that tenant. When process instances get started based on such definitions, they inherit this tenantId. Same for executions, tasks, etc.
Do note that you’ll need to add this tenantId also to all the queries your having.
It’s possible to use that Configuration in Spring Boot, however, you will have to overwrite the default processEngineConfiguration bean, as the default one won’t be multi-schema-multi-tenant enabled.
@fiki574 We want to use Single database with multiple tenants option and not two different database. Basically we are looking for shared DB & shared engine with multiple tenants.