Вопрос

Can different parts of the the OFBiz application connect to different databases? e.g: -Party Management => connect to database 1 -Catalog Management => connect to database 2 -Working in the same instance of Ofbiz application. My plan is to create tenants in OFbiz and have different parts of OFBiz connect to the tenant, while others connect to the default/original OFBiz database.

Это было полезно?

Решение

The short is yes, you can, the long answer is probably you don't want to do that because of existing interapp dependencies at entity level.

First you have to understand how all it fits together: Ofbiz entities are usually defined in entitymodel.xml and referenced in ofbiz-component.xml Most of the existing components have only this level of configuration. With such a configuration, the entities belong to the default group called "org.ofbiz". Then in entityengine.xml the group is assigned to a datasource:

<group-map group-name="org.ofbiz" datasource-name="localpostgres"/>

This is how a table is assigned to group, then the group is assigned to the database.

So to assign all the entities form a component to a new database what you have to do:

  1. Create a new entity group definition in each component and assign the entities to that group:<entity-group group="org.ofbiz.tenant" entity="Tenant"/>

  2. Reference the group definition from the ofbiz-component.xml <entity-resource type="group" reader-name="main" loader="main" location="entitydef/entitygroup.xml"/>

  3. In entityengine.xml assign the new group to a different datasource: <group-map group-name="org.ofbiz.tenant" datasource-name="localpostgres"/>

For an example have a look at olap and tenant groups.

You can do the above steps and have your entities in a separate database, if you are creating a new component or if you want to do that for the components in specialpurpose folder. If you want to do this to existing component from framework or applications folder (like the content component you mentioned) you will notice that components have dependencies (entity relations) and moving some of the entities to a separate database will break that.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top