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.
For POS specific data synchronisation, you can refer detail document which is specific to POS servers syncing. Below is step by step procedure with an example to run entity synchronisation feature of OFBiz. Current example shows the data syncing through http connection. There is also an option to use RMI service for data syncing.
Example:
Suppose, we have two OFBiz instances called ofbiz-master and ofbiz-slave.
We have to synchronise ofbiz-master server by pushing party and customers data from ofbiz-slave.
Similarly, we have to synchronise ofbiz-slave server from ofbiz-master by pulling data of new catalog, categories and products.
Initial Steps:
Setup a ofbiz-master server with required data
Set the Time Zone value of ofbiz-slave instance in ‘start.properties’ file of OFbiz similar to ofbiz-master instance or vice versa.
Set sequenced-id-prefix value for default delegator in ‘entityengine.xml’ on ofbiz-slave server
Set the domain/IP of target(ofbiz-master) server in ‘serviceengine.xml’ file for entity-sync-http on ofbiz-slave server
Set ‘maxPostSize’ value to "-1” for "http-connector” property in ‘framework/catalina/ofbiz-component.xml’ file on ofbiz-slave server
Get SSL certificate of ofbiz-master server and install it on ofbiz-slave server
Data Pull from ofbiz-master to ofbiz-slave server
Below is example to pull Products data from ofbiz-master to ofbiz-slave server.
Load below data on ofbiz-master server. This data defines the set of entities and packages that require to pull product data from master server. We can add/remove entities and packages as per data need
<EntityGroup entityGroupId="PRODUCT_PULL" entityGroupName="Pull catalog, categories and product data from master server to slave 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 server or run service ‘runPullEntitySync’ manually on ofbiz-slave server. We can schedule it as per requirement.
<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-slave 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-master from ofbiz-slave server
Below is example to push customer/party data from ofbiz-slave server to ofbiz-master server.
Load below data on ofbiz-slave server. This data defines the set of entities and packages that require to push customer data from ofbiz-slave server. We can add/remove entities and packages as per data need
<EntityGroup entityGroupId="PARTY_PUSH" entityGroupName="PUSH: ofbiz-slave to ofbiz-master 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 server or run service ‘runEntitySync’ manually from ofbiz-slave server
<!-- 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"/>