Alert | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
After
|
Table of Contents |
---|
Introduction
To sync data of specific entities or packages between two or more OFBiz instances, we can use EntitySync functionality of OOTB. Data synchronisation can achieve by pull and push of data between OFBiz instances.
...
Suppose, we have two OFBiz instances, one called "ofbiz-mastermain" and one called "ofbiz-slavesecondary".
We have to synchronise ofbiz-master main server by pushing party and customers data from the ofbiz-slavesecondary.
Similarly, we have to synchronise the data on the ofbiz-slave secondary with changes on the ofbiz-mastermain, by pulling data of new catalog, categories and products.
Initial Steps:
Setup a ofbiz-master main server with required data
Set the Time Zone value of ofbiz-slave secondary instance in ‘start.properties’ file of OFbiz similar to ofbiz-master main instance or vice versa.
Set sequenced-id-prefix value for default delegator in ‘entityengine.xml’ on ofbiz-slave secondary server
Set the domain/IP of target(ofbiz-mastermain) server in ‘serviceengine.xml’ file for entity-sync-http on ofbiz-slave secondary server
Set ‘maxPostSize’ value to "-1” for "http-connector” property in ‘framework/catalina/ofbiz-component.xml’ file on ofbiz-slave secondary server
Get SSL certificate of ofbiz-master main server and install it on ofbiz-slave secondary server
Data Pull from ofbiz-
...
main to ofbiz-
...
secondary server
Below is example to pull Products data from ofbiz-master main to ofbiz-slave secondary server.
Load below data on ofbiz-master main server. This data defines the set of entities and packages that require to pull product data from master main server. We can add/remove entities and packages as per data need
Code Block language xml <EntityGroup entityGroupId="PRODUCT_PULL" entityGroupName="Pull catalog, categories and product data from mastermain server to slavesecondary Server"/> <!-- Catalogs --> <EntityGroupEntry entityGroupId="PRODUCT_PULL" entityOrPackage="org.apache.ofbiz.product.catalog" applEnumId="ESIA_INCLUDE"/> <!-- Categories --> <EntityGroupEntry entityGroupId="PRODUCT_PULL" entityOrPackage="org.apache.ofbiz.product.category" applEnumId="ESIA_INCLUDE"/> <!-- Products --> <EntityGroupEntry entityGroupId="PRODUCT_PULL" entityOrPackage="org.apache.ofbiz.product.facility" applEnumId="ESIA_INCLUDE"/> <EntityGroupEntry entityGroupId="5507_2_PULL" entityOrPackage="org.apache.ofbiz.product.product" applEnumId="ESIA_INCLUDE"/> <EntityGroupEntry entityGroupId="5507_2_PULL" entityOrPackage="org.apache.ofbiz.product.feature" applEnumId="ESIA_INCLUDE"/> <EntityGroupEntry entityGroupId="5507_2_PULL" entityOrPackage="org.apache.ofbiz.product.price" applEnumId="ESIA_INCLUDE"/> <EntityGroupEntry entityGroupId="5507_2_PULL" entityOrPackage="org.apache.ofbiz.product.promo" applEnumId="ESIA_INCLUDE"/> <EntityGroupEntry entityGroupId="5507_2_PULL" entityOrPackage="org.apache.ofbiz.product.supplier" applEnumId="ESIA_INCLUDE"/> <EntitySync entitySyncId="PRODUCT_PULL" runStatusId="ESR_NOT_STARTED" syncSplitMillis="600000" syncEndBufferMillis="120000" keepRemoveInfoHours="24" forPullOnly="Y"/> <EntitySyncIncludeGroup entitySyncId="PRODUCT_PULL" entityGroupId="PRODUCT_PULL"/>
Load Schedule job data(defined below) on ofbiz-slave secondary server or run service ‘runPullEntitySync’ manually on ofbiz-slave secondary server. We can schedule it as per requirement.
Code Block language xml <RuntimeData runtimeDataId="PRODUCT_PULL"> <runtimeInfo><![CDATA[<?xml version="1.0" encoding="UTF-8"?> <ofbiz-ser> <map-HashMap> <map-Entry> <map-Key> <std-String value="entitySyncId"/> </map-Key> <map-Value> <std-String value="PRODUCT_PULL"/> </map-Value> <map-Key> <std-String value="remotePullAndReportEntitySyncDataName"/> </map-Key> <map-Value> <std-String value="remotePullAndReportEntitySyncDataHttp"/> </map-Value> </map-Entry> </map-HashMap> </ofbiz-ser> ]]></runtimeInfo> </RuntimeData> <!-- Schedule job onofbiz-slavesecondary server on daily basis at zero hour of day --> <JobSandbox jobId="PRODUCT_PULL" jobName="PULL Products" runtimeDataId="PRODUCT_PULL" runTime="2000-01-01 00:00:00.000" serviceName="runPullEntitySync" poolId="pool" runAsUser="system" tempExprId="HOUR_00"/>
Data Push to ofbiz-
...
main from ofbiz-
...
secondary server
Below is example to push customer/party data from ofbiz-slave secondary server to ofbiz-master main server.
Load below data on ofbiz-slave secondary server. This data defines the set of entities and packages that require to push customer data from ofbiz-slave secondary server. We can add/remove entities and packages as per data need
Code Block language xml <EntityGroup entityGroupId="PARTY_PUSH" entityGroupName="PUSH: ofbiz-slavesecondary to ofbiz-mastermain Server"/> <!-- Party, Contact and userlogin --> <EntityGroupEntry entityGroupId="PARTY_PUSH" entityOrPackage="org.apache.ofbiz.party.party" applEnumId="ESIA_INCLUDE"/> <EntityGroupEntry entityGroupId="PARTY_PUSH" entityOrPackage="org.apache.ofbiz.party.contact" applEnumId="ESIA_INCLUDE"/> <EntityGroupEntry entityGroupId="PARTY_PUSH" entityOrPackage="org.apache.ofbiz.security.securitygroup" applEnumId="ESIA_INCLUDE"/> <EntityGroupEntry entityGroupId="PARTY_PUSH" entityOrPackage="org.apache.ofbiz.security.login" applEnumId="ESIA_INCLUDE"/> <EntityGroupEntry entityGroupId="PARTY_PUSH" entityOrPackage="org.apache.ofbiz.common.user" applEnumId="ESIA_INCLUDE"/> <EntitySync entitySyncId="PARTY_PUSH" runStatusId="ESR_NOT_STARTED" syncSplitMillis="600000" syncEndBufferMillis="120000" targetServiceName="remoteStoreEntitySyncDataHttp" targetDelegatorName="default-no-eca" keepRemoveInfoHours="24" forPushOnly="Y"/> <EntitySyncIncludeGroup entitySyncId="PARTY_PUSH" entityGroupId="PARTY_PUSH"/>
Load Schedule job data (defined below) on ofbiz-slave secondary server or run service ‘runEntitySync’ manually from ofbiz-slave secondary server
Code Block language xml <!-- Runtime data for job--> <RuntimeData runtimeDataId="PARTY_PUSH"> <runtimeInfo><![CDATA[<?xml version="1.0" encoding="UTF-8"?> <ofbiz-ser> <map-HashMap> <map-Entry> <map-Key> <std-String value="entitySyncId"/> </map-Key> <map-Value> <std-String value="PARTY_PUSH"/> </map-Value> </map-Entry> </map-HashMap> </ofbiz-ser> ]]></runtimeInfo> </RuntimeData> <!-- Schedule service to run daily at the end of day, frequency can be modified as per requirement --> <JobSandbox jobId="PARTY_PUSH" jobName="Push Customers" runtimeDataId="PARTY_PUSH" runTime="2000-01-01 00:00:00.000" serviceName="runEntitySync" poolId="pool" runAsUser="system" tempExprId="HOUR_23"/>
...