Chapter 6. Data Synchronization

If you are a mobile device user, it is likely that you would have performed a sync at one point in time (with or without being aware of it). We are all familiar with the convenience of being able to just dock our PDA devices and have our calendars, tasks, and contacts automatically synced to our desktop machines.

The synchronization process is a necessity for any type of mobile device, whether it's a Smart Phone, iPhone, or a Pocket PC. The core of this necessity is simple—people need to have access to their data when they're on the move and when they're back at the office, and this data needs to be consistent—wherever they're accessing it from.

In a business scenario, the importance of this necessity increases manifold—it's not just about your personal data anymore. The data you've keyed in on your PDA needs to be synced to the server so that it can be shared with other users, used to generate reports, or even sent for number-crunching. With hundreds of mobile users synchronizing their data and server-side applications updating this data at the same time, things can quickly get messy. The synchronization process has to ensure that conflicts are gracefully handled, auto-generated numbers don't overlap, that each user only syncs down the data they're meant to see, and so on.

Fortunately for us, the folks at Microsoft and Oracle have gone through much of the brainstorming for us and have created rich frameworks which we can easily use to initiate a sync job. In this chapter, we study two such frameworks in detail—the Microsoft Synchronization Services Framework and the Oracle Mobile Server suite. We will take a look at the following topics in detail:

  • An overview of the various synchronization methods available for both SQL Server CE and Oracle Lite
  • How to sync the Sales Force database tables using the Microsoft Synchronization Services Framework and the Oracle Mobile Server
  • How to synchronize externally stored files to the server
  • How to create a network-aware sync module

Overview of the different data synchronization methods available for Microsoft SQL Server CE

Microsoft provides various methods to sync data between the mobile device and the database server. Let's take a look at these methods in detail:

SQL Remote Data Access (SQLRDA)

SQLRDA was one of the earliest methods of data synchronization between a mobile device and an SQL Server database. It allowed the mobile application to issue push or pull commands to sync data upwards or downwards from the SQL Server database.

Through the Client Agent, the mobile application could issue these commands to the Server Agent (which sits behind the IIS web server). The Server Agent then executes the requested commands directly on the SQL Server database.

Note

It is important to note that SQLRDA is being phased out by Microsoft in favour of the newer Microsoft Synchronization Services Framework. You should use this new framework instead when you implement your synchronization projects.

Merge replication

Merge replication provides synchronization capability via a publisher-subscriber model. The database at the server side is called the Publisher. It makes a publication (a set of database objects) available for replication. The mobile application is the Subscriber. The setting up of merge replication is a two-step process:

  1. A publication is created on the database.
  2. A subscriber subscribes to the publication.

After that, any changes made to the data on the client-side can be synced to the publisher through this replication framework. The architecture of the merge replication framework is depicted as follows:

Merge replication

In the previous diagram, the mobile application uses the replication objects to communicate with the SQL Server CE Client Agent, which passes the changes made to the corresponding Server Agent via IIS. The SQL Server Reconciler is the component that will merge all changes from the Subscriber to the Publisher.

Microsoft Synchronization Services

The Microsoft Synchronization Services Framework allows a server database to not only sync with mobile device clients but also with desktop clients. It is also able to sync data from different types of data sources to the server. For instance, this framework provides the Sync Services for Filesystems component that allows you to easily sync folders or files with another system.

Note

Microsoft uses certain terminologies in this framework. The client-side database is called the Local Database Cache and the server-side database is called the Remote Database.

The Microsoft Synchronization Services Framework provides sync functionality in the form of Sync providers, in much the same way as database providers provide data access functionality. The client-side Sync provider and server-side Sync provider communicate with each other through a Windows Communication Framework (WCF) service. This setup is depicted as follows:

Microsoft Synchronization Services

The Microsoft Synchronization Services Framework is extensible—through the use of different providers, you can implement sync functionality for different types of data and data sources. You can even create your own custom sync providers to latch on to the framework.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.109.151