Access to add and change pages is restricted. See: https://cwiki.apache.org/confluence/display/OFBIZ/Wiki+access

Commit history and discussions regarding these enhancement can be tracked from JIRA task Unable to render Jira issues macro, execution error.

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.

Some enhancements are proposed in multi tenancy functionality of Apache OFBiz to provide support of following features:

  • 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

Gradle

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

2) Set property 'multitenant=Y' in file framework/common/config/general.properties .

3) Create new tenant by using createTenantant target 'create-tenant'.

4) Do ant clean / ant build and restart your server.

5) For local instance setup, you will need to do an entry of new domain name in /etc/hosts with ip address of machine, like:  127.0.0.1  localhost abc.com

6) Make Apache connector related settings so that you do not need to use port information in url

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) For back-end applications, domain name field is optional. You can access back-end applications by entering tenantId from login page OR by entering url with domain name as described above in #7.

  • No labels