Microsoft Sync Framework basics 1: Microsoft Sync Framework Overview

Source: Internet
Author: User
Tags microsoft download center
Document directory
  • Introduce Microsoft Sync Framework
  • Install Microsoft Sync Framework
  • A simple example
Preface

Recently, the Team took over development work related to Microsoft Sync Framework (MSF), so it is a great opportunity to study and learn about Microsoft Sync Framework, an excellent synchronization tool. Of course, the first step is to learn how to use it. Below is a series of learning notes for me to learn Microsoft Sync Framework. In the spirit of sharing learning and making common progress, I will send my series of notes to the blog garden. We hope to discuss and learn with our colleagues who use Microsoft Sync Framework. I hope you will not correct the errors or mistakes in the synchronization field.

 

Next we will give a rough list of the series of essays, which will be fine-tuned as needed during the writing process.

Directory

Part 1 basics of Microsoft Sync Framework

Microsoft Sync Framework Overview

Microsoft Sync Framework architecture and Runtime

Microsoft Sync Framework metadata and synchronization process

Part 2 synchronize Databases

Database Synchronization Overview

Example: Synchronize SQL Server and SQL Server Compact

Set Synchronization

Part 3 file synchronization

File sync Overview

Example

Part 4 synchronous Web Feeds

Introduction to synchronous Web Feeds

Part 5 use a custom provider

User-Defined provider Basics

Implement simple custom providers

Implement standard custom providers

Part 6 Microsoft Sync Framework 4.0 CTP

Introduction to CTP

Sync Protocol Specification

Example: create and use a Sync Service

SyncSvcUtil Introduction

Introduction to SyncSvcUtilHelper

 

Introduction to Microsoft Sync Framework advantages of Microsoft Sync Framework Synchronization

Before learning MSF in depth, we need to first understand the concept of synchronization and why synchronization is necessary. To put it simply, synchronization is to maintain data consistency between the two endpoints/data storage areas. When the content in the two data storage zones is completely consistent, we can say that they are synchronized with each other.

For example, if you want to manually synchronize two databases, we usually do this:

  • Find the changes in the source database
  • Send changes to the target database
  • Apply changes to the target database
  • Repeat the preceding steps to exchange the source and target databases.

So why do we need to create a synchronization mechanism for a program, data storage area, or services? The most common benefits of synchronization are listed below:

Offline operation:The biggest advantage of synchronization is that it enables the program to support offline operations. If we create a synchronization mechanism for the program, the program user can interact with the local data. It is not used until we need to download new data from the server or obtain a network connection again.

Create faster and richer user interfaces:By setting up a synchronization mechanism for the program, we can create a richer user interface without worrying about program performance issues. Because all the data is usually obtained locally, the program will provide us with more rapid feedback.

Reduce network overhead:Synchronization programs generally support incremental updates for upload/download, reducing the amount of data transmitted over the network.

The above only lists some of the benefits of synchronization. Now, we should be able to understand the necessity of synchronization. Next we will discuss how to implement synchronization.

Synchronization challenges

Although synchronization is very simple in theory, it is very difficult to practice. Understanding these issues will help us better understand the importance of Microsoft Sync Framework. Specifically, the problems and challenges in the synchronization process are as follows:

Handle errors and failures: Suppose we are synchronizing two databases. A program error occurs, such as database connection timeout or a constraint is violated when the application is changed to the target database, what should I do with the synchronized records?

Network failure: In the above example, if the network suddenly becomes invalid when a database gets updates from another database, how should we deal with it?

Conflict Detection: A conflict occurs when the same data project is simultaneously modified at both ends of synchronization. What should we do?

Obviously, we can write our own code to solve all the above problems. But if we have a synchronization framework that can solve all these problems for us, we can focus on implementing our own business logic. Well, it's time to introduce Microsoft Sync Framework. Microsoft provides us with this synchronization Framework, which not only provides built-in functions to solve the above problems, in addition, two data storage zones can be synchronized in any network and any protocol.

Why Microsoft Sync Framework

Microsoft Sync Framework provides us with the biggest benefit: its synchronization function supports offline and online data operations. The main purpose of MSF is to allow our data to be synchronized and integrated into any data source, regardless of the type of data.

Let's take a look at Microsoft's official definition of Microsoft Sync Framework: Sync Framework is a fully functional synchronization platform that enables collaboration and offline access between applications, services, and devices. Sync Framework provides some technologies and tools that support roaming, sharing, and obtaining data offline. By using the Sync Framework, developers can build a synchronization ecosystem and integrate any application with data in any storage area by using any protocol on any network.

The following are some of the main features of Microsoft Sync Framework:

  • A powerful synchronization platform independent of underlying data storage, data types, and Protocols
  • Scalable Provider Model
  • Filter used to synchronize data subsets
  • Built-in Automatic and custom conflict solutions
  • Synchronization of file systems, databases, RSS, and Atom feeds
  • Supports peer-to-peer collaboration and client-server Topology
  • Provides APIs for both hosted and unmanaged code.
Install Microsoft Sync Framework 2.1 in Microsoft Sync Framework

Currently, the latest version of Microsoft Sync Framework is 2.1 (except for Sync Framework 4.0 CTP, which will be mentioned below). We can install the development components through the SDK installation package. Download the installation package from Microsoft Download Center and follow the installation instructions provided on the website.

On the x86 platform, the x86 installation package installs the main components in Program Files \ Microsoft SDKs \ Microsoft Sync Framework \ 2.1 and adds the hosted DLL to the Global Assembly Cache (GAC ). On the 64-bit platform, install the x86 and x64 installation packages in Program Files (x86), Microsoft SDKs, Microsoft Sync Framework, and 2.1.

Sync Framework 2.1 includes the following new features and enhancements:

Database provider

  • SQL Azure Synchronization
  • Batch application changes
  • Parameter-Based Filtering
  • Delete scopes and templates
  • Update metadata format
  • SQL Server Compact 3.5 SP2 compatibility
Microsoft Sync Framework 4.0 CTP

Microsoft Sync Framework 4.0 community technology Preview (CTP) is built on Sync Framework 2.1. In fact, Sync Framework 2.1 is the prerequisite for installing MSF 4.0 CTP, although the final release version of Sync Framework 4.0 will be a complete installation package, and Sync Framework 2.1 is no longer required.

Follow these steps to install Microsoft Sync Framework 4.0 CTP:

1. Install the Microsoft Sync Framework 2.1 SDK, see the previous section, or directly download from here: http://www.microsoft.com/download/en/details.aspx? Displaylang = en & id = 23217

2. click the following link to Sync Framework online survey to complete Microsoft's online survey on Sync Framework:

3. Once you submit this online survey, you will see the download link of Sync Framework 4.0 CTP at the Microsoft Connect site:

Microsoft Sync Framework 4.0 CTP extends Sync Framework 2.1 to allow us to create offline applications for any platform. In versions earlier than the Sync Framework, we must use a Windows system installed with the Sync Framework runtime as the client. CTP allows other Microsoft platforms such as Silverlight, Windows Phone 7, and Windows Mobile, as well as other non-Microsoft platforms such as iPhone, Android, and Blackberry, without installing any Sync Framework components for clients on these platforms, this is because all the synchronization logic is moved from the client to the server. So how does Microsoft Sync Framework 4.0 obtain this cross-platform capability? The answer is that it defines a new HTTP-based synchronization Protocol: Sync Protocol.

This series of blogs mainly aim to Sync Framework 2.1. Of course, I will also give a detailed introduction to Microsoft Sync Framework 4.0 CTP in a special chapter.

A simple example

The following example uses the Sync Framework built-in file synchronization provider to synchronize two directories.

  1. Create a Console Application named FileSyncSample.
  2. Add a reference to the Microsoft. Synchronization and Microsoft. Synchronization. Files assembly.
  3. Modify the Main function to the following format:
Using System;
Using Microsoft. Synchronization. Files;
Using Microsoft. Synchronization;

Namespace FileSyncSample
{
Class Program
{
Static void Main (string [] args)
{
// Create Source Sync Provider
FileSyncProvider sourceProvider = new FileSyncProvider (@ "C: \ TestSync1 ");
// Create Target Sync Provider
FileSyncProvider destProvider = new FileSyncProvider (@ "C: \ TestSync2 ");

// Create Sync Orchestrator (synchronous session)
SyncOrchestrator syncAgent = new SyncOrchestrator ();
SyncAgent. LocalProvider = sourceProvider;
SyncAgent. RemoteProvider = destProvider;

// Start Synchronization
SyncAgent. Synchronize ();

Console. WriteLine ("synchronization completed ");
}
}
}

The above simple program completes synchronization between two directories. Please create a corresponding directory and file to verify its synchronization function, I believe you will be as surprised to me that the Sync Framework makes our synchronization work so simple. Let's join in the world of Microsoft Sync Framework.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.