...
Info | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Commit history and discussions regarding these enhancement can be tracked from JIRA task
|
Introduction
Multi-tenancy is the ability to run separate data instances (tenants) from a single code base. In this case each tenant will have its own database. A user logs into a data instance (or tenant) by specifying the tenant ID in the login form or by hitting tenant specific url . A default database is still used although.
...
- To run front store application on multi tenant environment
- To make configuration attribute specific to tenant.
- To specify domain name for each tenant and to run tenant instance on specified domain name.
- To support multiple domain for each tenant so that tenant can be used with multi-site functionality
Here is the brief description of each feature
Multi-tenant Support At Front Store
Currently we are having multi-tenancy support at back-end only where we can login with tenant# and the system started pointing to the database of that particular tenant. Now we have provided support of multi-tenancy at front store as well which can be accessed by tenant specific domain name e.g. abc.com.
Tenant Specific Configuration Attributes
With the implementation of these enhancement features tenants can have their own configurations / settings also for front store. In other words we can say that now it is possible to have tenant specific settings at front store like theme, layouts, catalog etc. This can be achieved by using SystemProperty entity through EntityUtil methods.
Run Tenant Instance On Specified Domain Name
This functionality enables the service provider to specify domain name for each tenant and run the instance on specified domain name. Suppose we have a tenant 'XYZ' with domain name xyz.com. Now we can access XYZ specific database by hitting xyz.com in the browser.
Multiple Domains And Multi Site Functionality
This functionality also enables support for multiple domains and sub domains for tenants. This feature can be used in multi-site functionality. For example, suppose a tenant have multiple sites like abc.com and abc.org or have sub domains likd abc.watch.com and abc.cloths.com . If any user hits any of the above urls, the system will point to the _Single_ database of tenant 'abc'.
To provide support for above mentioned features we will have to make following changes:
Creation Of New Entity 'TenantDomainName'
To save information related to Tenant and its domain name we have an entity named 'Tenant' in OFBiz. In this entity tenantId is primary key, so we can store only one domain name for a particular tenant. There is a problem when a tenant have more than one domain name or we can say sub domains. So we have introduced a new entity 'TenantDomainName' which will have domainName as primary key and tenantId as a non-primary key column. Hence we can save multiple domain names for a tenant.
Enhancements In 'create-tenant' Target
In order to add support to add domain name while setting up new tenant, 'create-tenant' target has been modified. Now system will ask "Enter domain name for tenant(optional):" at the time of tenant creation with other informations. This domain name will be stored in new entity 'TenantDomainName' along with tenantId. At the time of url hit, system will look for the domain name, find the corresponding tenantId and will start pointing to corresponding database.
Following steps should be followed to have support for above mentioned features in your application
Warning | ||
---|---|---|
| ||
If you use a "new" version which does not embed Ant nor any build.xml file, it means that you should use Gradle tasks instead of below Ant targets, please refer to the Gradle documentation in wiki |
1) Move your code base to -r1658369
...
3) Create new tenant by using ant createTenantant target 'create-tenant' . (You can also use create-tenant-on-Derby, create-tenant-on-MySQL, create-tenant-on-Oracle, create-tenant-on-PostgreSQL).
4) Do ant clean / ant build and restart your server.
...
7) Go to front-end by entering url with domain name without port like: http://abc.com/ecommerce/ or with port like: http://abc.com:8080/ecommerce/
8) Login to For back-end applications, domain name field is optional. You can access back-end applications by entering login id , password and tenant id on login form or by tenantId from login page OR by entering url with domain name as described above in #7.