Creatio development guide
PDF
This documentation is valid for Creatio version 7.16.0. We recommend using the newest version of Creatio documentation.

Sync Engine synchronization service

Glossary Item Box

Creatio implements a mechanism for synchronization with remote repositories (Sync Engine). Sync Engine enables users to create, modify, and delete Entity objects in Creatio based on the data imported from remote repositories, as well as export data to remote repositories.

The synchronization process requires the SyncAgent class implemented in the Terrasoft.Sync namespace on the application core level.

Sync Engine synchronization service workflow

Classes used by the synchronization mechanism

  • Synchronization agent (SyncAgent) – the class’s only public method—Synchronize—initiates synchronization between the data repositories passed as arguments.
  • Synchronization context (SyncContext) – the class is an aggregation of repositories and metadata required by SyncAgent.
  • Provider – a specific data repository that hosts synced data.
    Local storage (LocalProvider) – enables working with LocalItem in Creatio.
    Remote storage (RemoteProvider) – the remote service or application whose data sync with Creatio.
  • Synchronization item (SyncItem) – a set of remote and local objects mapped one-to-one.
    Remote synchronization item (RemoteItem) – an atomically synced set of data from a remote repository. The set can comprise one or several entities (records) from a remote repository.
    Synchronization entity (SyncEntity) – a wrapper for specific Entity objects. SyncEntity is required to work with Entity: as the synchronized object, as the state of the object, or as the action to apply to the Entity (add, delete, modify).
    Local item (LocalItem) – one or several Creatio objects synchronized with a remote repository as a single item. In turn, a remote synchronization item converted into entities of the LocalItem type contains a set of SyncEntity instances.
  • The SysSyncMetadata metadata table contains service information on the synchronized items. Essentially, it is a RemoteItem-LocalItem bridge table. Learn about metadata in more detail in the “Synchronizing metadata in Creatio” article.

The general synchronization algorithm

Before initiating synchronization, create a SyncAgent instance and a SyncContext object, then use Creatio data to update the records in the metadata table. To do this, call the CollectChangesInSyncedEntities method of a class that implements the IReplicaMetadata interface.

To update metadata records:

  1. If a previously synced Creatio entity has been changed since the last synchronization, the modification date of the corresponding metadata record changes. The LocalState property is set to “Modified,” and the LocalStore identifier is set as the modification source.
  2. If a synced Creatio entity has been deleted since the last synchronization, the LocalState property of the corresponding metadata record is set to “Deleted.”
  3. A Creatio entity that lacks a synchronization metadata record is ignored.

After that, the synchronization process of repositories commences:

  1. All changes are requested one by one from remote repositories.
  2. The synchronization process requires to retrieve the metadata for each remote item.

The following scenarios are possible: 

  1. If metadata retrieval fails, the item is considered new. Such an item is converted into a Creatio item and saved. To populate the synchronization item, the application calls the FillLocalItem method of a specific RemoteItem instance. A metadata record is also saved. The metadata includes the Id of the remote storage, the Id of the remote item, the creation and modification date (set to current), and the source of creation and modification (set to the remote storage identified).
  2. Successful retrieval of the metadata implies that the item has already been synced with Creatio. Move on to version conflict resolution. The latest local or remote changes (implemented in the RemoteProvider) have a priority by default.
  3. The metadata for the current pair of synced items is updated.

After iterating through all the modified remote items, the metadata (between the previous and the current synchronizations) is bound to contain items changed locally but not remotely.

  1. Retrieve elements changed in Creatio between the previous synchronization and the beginning of the current synchronization.
  2. The changes are applied in the remote storage.
  3. Update the modification date of elements in the metadata (Creatio change source).

After that, add the new Creatio records that have not yet been synced to the remote storage. Add the metadata for the new items as well.

Sync Engine synchronization service compatibility with Creatio products

The Sync Engine synchronization service is compatible with all Creatio products.

Sync Engine synchronization service deployment options

The Sync Engine synchronization service is hardcoded into the core of the application and does not require additional settings.

See Also

© Creatio 2002-2020.

Did you find this information useful?

How can we improve it?