05-15-2017 02:21 AM
Hello,
I try to implement a Multi-Schema Multi-Tenancy with the MultiSchemaMultiTenantProcessEngineConfiguration configuration class. I integrate with Activiti only through rest, my main app is written in Python.
Every request I do to activiti has the tenantId information, then it should be easy for activiti to route the query to the correct DB, however I need to crate a class implementing the TenantInfoHolder.
My question is, where do I hook this class in activiti-rest code to be sure the tenantId will be always set when a DB query is done ?
Thank you !
05-15-2017 10:18 AM
The class that implements TenantInfoHolder is registered when you create the configuration for MSMT.
It is a relatively simple interface and in general all it needs to do is correlate your current userid to the tenant id.
Alternatively, if the tenant_id will be included in the url you can use a filter to set/get a thread local variable:
protected static final ThreadLocal<Long> currentTenantIdPlaceHolder = new ThreadLocal<Long>();
...
...
@Override
public void setCurrentTenantId(String tenantId) {
currentTenantIdPlHolder.set(Long.valueOf(tenantId));
}
Also, make sure you take a look at the following blog post:
Multi-Tenancy with separate database schemas in Activiti | Small steps with big feet
Cheers,
greg
05-15-2017 10:18 AM
The class that implements TenantInfoHolder is registered when you create the configuration for MSMT.
It is a relatively simple interface and in general all it needs to do is correlate your current userid to the tenant id.
Alternatively, if the tenant_id will be included in the url you can use a filter to set/get a thread local variable:
protected static final ThreadLocal<Long> currentTenantIdPlaceHolder = new ThreadLocal<Long>();
...
...
@Override
public void setCurrentTenantId(String tenantId) {
currentTenantIdPlHolder.set(Long.valueOf(tenantId));
}
Also, make sure you take a look at the following blog post:
Multi-Tenancy with separate database schemas in Activiti | Small steps with big feet
Cheers,
greg
05-16-2017 08:29 AM
Thank you Greg,
I will try to hook in the BasicAuthenticationProvider class !
Stephane
05-16-2017 08:42 AM
Sounds like a good option. God luck.
Greg
Explore our Alfresco products with the links below. Use labels to filter content by product module.