Advantage Developer Zone


Replication Strategies

Wednesday, November 7, 2007

Replication is a powerful way to share data between two or more sites. Advantage Replication pushes changes from a server using a publication to one or more subscribers. This allows the subscribers to access the most current information from the publisher. For example, a price list may be replicated from the main office down to the various sales offices to ensure that sales representatives have the most current pricing information.

There are many cases where simple one way replication is not enough to meet your needs. Several sales offices may need to update other information as well. Although Advantage Replication is not synchronization, with the proper configuration it can be used to handle this situation as well.

Replication Terminology

Advantage Replication is configured within a data dictionary by creating a publication. The publication defines which tables within the database will be replicated. Horizontal and vertical filters can be applied to these tables ensuring that the correct data is replicated. After the publication has been defined, subscriptions can be added. A subscription defines the connection type and destination of the server which will receive the information.

Servers which push data are referred to as Publishers and servers that receive information are called Subscribers. Servers can be both a Publisher and Subscriber allowing for two way replication. For more information, refer to the Replication Tech Tip, Replication Online Seminar, or the Advantage Help files.

N-Way Replication

Replication to multiple subscribers can be accomplished in several ways. A publisher can have several subscribers which all receive changes as they are made at the publisher. This is simple to configure and ensures that data changes are replicated whenever a connection exists between Publisher and Subscriber. This only requires replication to be enabled on a single Advantage Server. The configuration may look something like the diagram below.


Replication can also be forwarded from one server to another. This allows the first subscriber to send changes it receives to its subscribers. Configuring replication this way allows for more control of what data is replicated without creating multiple publications. For example the corporate office may replicate to each of the regional offices. The regional offices in turn replicate a portion of this information down to the local offices. If the corporate office was the only publisher it would have to have a specific publication for replicating the proper information to the local offices in each region. Additionally it would require a subscription for each of the local offices. By forwarding the replication from the regional offices the local publications and subscriptions can be managed by the regional offices. A simple forwarding diagram is below.


Multiple Two-way Replication

The examples above involve one way replication where information is only being replicated from one Publisher to one or more Subscribers. Many times it is necessary to replicate information both ways. The simplest case is two stores sharing information. Each store is both a Publisher and Subscriber. This allows for all changes made at either store to be replicated to the other. Remember that by default Advantage Replication works on a “last update wins” model. This means that any changes made to the same record will only reflect the most recent change.

You can change the default behavior by creating “ON CONFLICT” triggers on specific tables. When these triggers are created on a table the replication engine will examine the record for changes since the last replication. If a change is detected then the trigger code is executed. Remember that any changes made by the trigger will not be reflected at the publisher. For more information about handling replication conflicts refer to the Resolving Replication Conflicts tech tip.

Multi way replication can become very complicated quickly especially when several locations are involved. Consider the following diagram.


As you can see the number of publications and subscriptions increases very quickly. Each server requires at least one publication and three subscriptions for a minimum of 12 subscriptions in the solution.

A common way to simplify this type of environment is to use a Spoke and Hub configuration. In this configuration a central server is used to manage replicating to all the locations. Each location has a publication and uses the central server as its subscriber. The central server has one or more publications, depending on the requirements, and has each of the locations as a subscriber. This configuration is illustrated below.



Replication is a powerful solution for sharing data between two or more servers. With the proper planning and infrastructure it can add tremendous value to your application. Proper design and planning are critical whenever considering a replication solution.