flexible data synchronization with microsoft sync framework
DESCRIPTION
My Live Webcast Session on September 19, 2009 during the MY-TG SQL Server Community Series.TRANSCRIPT
Artemakis Artemiou
Microsoft SQL Server MVP
MCP, MCTS (Charter Member)
CDNUG Lead
INETA-Europe Country Leader (CY)
September 19, 2009
Flexible Data Synchronization with
Microsoft Sync Framework
About me
• Microsoft SQL Server MVP
• MCP, MCTS:SQL Server 2005 / SQL Server 2008 (Charter Member)
• Cyprus .NET User Group (CDNUG) Lead
• INETA-Europe Country Leader (CY)
• Analyst/Programmer/Consultant
• H.S.Data Ltd
• Email: [email protected]
• Blog: http://aartemiou.blogspot.com
What Will We cover?
• Remotely vs. Occasionally Connected Applications
• Why Use a Framework?
• Fundamentals of Data Synchronization
• Sync Framework Overview
• Sync Framework Runtime
• Synchronizing Databases
• Creating a Sync Ecosystem from Scratch
• Synchronizing Files
• Synchronizing Web Feeds
• Summary
3- Flexible Data Synchronization with Microsoft Sync Framework -
Remotely Connected Applications
4- Flexible Data Synchronization with Microsoft Sync Framework -
Central
Data source
Web
Server
INTERNET
• Mobile and remote workers
– Laptops
– Office desktops
– Smartphones
– PDAs
• Data is accessed using:
– VPN connections
– Web servers
– Other connectivity methods
Occasionally Connected Applications
5- Flexible Data Synchronization with Microsoft Sync Framework -
Central
Data source
Web
Server
INTERNET
Standalone Database Applications
• OCA
– Allows remote workers to
continue to access their data
– Data is stored locally on the
user’s device
• Data Synchronization capabilities
– Used by an OCA in order to
populate a user’s local database
Why Use a Framework?
• Synchronization is a difficult task
– Data conflicts detection/resolution
– Interruptions
– Restarts
– Managing deleted items
– Synchronization loops
– …
6- Flexible Data Synchronization with Microsoft Sync Framework -
Fundamentals of Data Synchronization
• Data Synchronization
– Synchronize changes between a client-side database and a server
database
• Main Advantage
– Users are no longer required to have a constant network
connection to access their information
• Basic components
– Synchronization session
– Two Synchronization providers (source & destination)
7- Flexible Data Synchronization with Microsoft Sync Framework -
Fundamentals of Data Synchronization
• Synchronization Algorithm (one-way)
1. Session gets the current knowledge of the destination replica
and sends it to the source provider.
2. Source provider enumerates changes that are not contained in
the destination knowledge.
3. Source provider sends changes to the session.
4. Session detects conflicts and applies changes to the destination
replica through the destination provider.
• Two-way Synchronization Algorithm
– Achieved by two one-way synchronizations
8- Flexible Data Synchronization with Microsoft Sync Framework -
Sync Framework Overview (I)
• Terminology
– Replica: Particular repository of data to be synchronized
– Provider: S/W component that represents a replica for
synchronization
• Enables collaboration and offline access for:
– Applications, Services & Devices
• Features technologies that enable:
– Roaming, Sharing & Taking data offline
• Ability to create custom synchronization providers
9- Flexible Data Synchronization with Microsoft Sync Framework -
Sync Framework Overview (II)
• Supplied Providers
– Sync Services for ADO.NET
– Sync Services for File Systems
– Sync Services for FeedSync (RSS & ATOM feeds)
• Participant
• The combination of a provider and its associated replica
• Participant Types
– Full
– Partial
– Simple
10- Flexible Data Synchronization with Microsoft Sync Framework -
Sync Framework Runtime (I)
• Core Components
11- Flexible Data Synchronization with Microsoft Sync Framework -
Data
SourceMetadata
Data
SourceMetadata
Sync Service Provider
Microsoft Sync
Framework Runtime
Sync Service Provider
Microsoft Sync
Framework Runtime
Sync Session
Sync Framework Runtime (II)
• Synchronization Flow1. Sync Session Initiated with Destination
2. Destination Prepares and Sends Knowledge
3. Destination Knowledge used to Determine Changes to be sent
4. Change Versions and Source Knowledge sent to Destination
5. Local Version Retrieved for Change Items and Compared against Source
Version and Knowledge
6. Conflicts are Detected and Resolved or Deferred
7. Destination Requests Item Data from Source
8. Source Prepares and Sends Item Data
9. Items are applied at Destination
12- Flexible Data Synchronization with Microsoft Sync Framework -
Synchronizing Databases
• Remote Data Access (RDA)
– Synchronize a SQL Server Compact 3.5 database with a database on
another edition of SQL Server
• Merge replication
– Synchronize different editions of SQL Server (including SQL Server
Compact 3.5)
• Sync Framework– Synchronize different editions of SQL Server (including SQL Server
Compact 3.5)
– Enables a developer to easily create views of data on the client that are
based on a server database or another data source
13- Flexible Data Synchronization with Microsoft Sync Framework -
Creating a Sync Ecosystem
from Scratch
• Development Environment
– Visual Studio 2008 SP1
– .NET Framework 3.5
– SQL Server 2008 SP1
– SQL Server Compact 3.5
– Sync Framework 2.0 CTP2
• Data Source
– Relational: SQL Server 2008 Database
14- Flexible Data Synchronization with Microsoft Sync Framework -
- Demo -
15- Flexible Data Synchronization with Microsoft Sync Framework -
Creating a Sync Ecosystem
from Scratch (Databases)
Synchronizing Files (I)
• Sync Services for File Systems provider
– Synchronize two file system locations (can either be local folders
or network shares)
– Changes to existing files are also synchronized
– Uses Sync Framework’s metadata model
– Enables peer-to-peer sync of file data with support for arbitrary
topologies (client/server, full-mesh, P2P) including support for
removable media
16- Flexible Data Synchronization with Microsoft Sync Framework -
Synchronizing Files (II)
• Enabled Scenarios
– Multi-master file sync between multiple PCs
– Synchronization between PCs using a USB Drive
– Taking a network share offline
– Maintaining a backup copy of files
• Implementation
– SyncOrchestrator object
– FileSyncProvider object
• SourceProvider
• DestinationProvider
17- Flexible Data Synchronization with Microsoft Sync Framework -
Synchronizing Web Feeds (I)
• Sync Framework Web synchronization components
– Enable a replica to publish its data to interested subscribers as an
RSS or Atom feed
• A Feed producer object provides the following:
– A synchronization provider that represents the replica to be
produced
– ID and item converter objects
– A stream that contains an empty RSS or Atom feed
18- Flexible Data Synchronization with Microsoft Sync Framework -
Synchronizing Web Feeds (II)
• Sync Framework Web synchronization components
– Enable a replica to consume an RSS or Atom feed and apply feed
items to its data store
• A Feed consumer object provides the following:
– A synchronization provider that represents the replica where
converted feed items will be applied
– ID and item converter objects
– A stream that contains the RSS or Atom feed to be consumed
19- Flexible Data Synchronization with Microsoft Sync Framework -
- Demo -
20- Flexible Data Synchronization with Microsoft Sync Framework -
Synchronizing Files
Summary
21- Flexible Data Synchronization with Microsoft Sync Framework -
• Data Synchronization With Ease – Sync Framework
– Occasionally Connected Systems
– Efficient conflict handling
– Flexible Synchronization Algorithm
• Sync Framework Supplied Providers
– Sync Services for ADO.NET
– Sync Services for File Systems
– Sync Services for FeedSync (RSS & ATOM feeds)
• The Future
– Codename "Huron" - Sync Enabled Cloud Data Hub
Resources
22- Flexible Data Synchronization with Microsoft Sync Framework -
• Microsoft Sync Framework
– Blog: http://blogs.msdn.com/sync/
– MSDN Library: http://msdn2.microsoft.com/library/bb902854(sql.100).aspx
– Developer Center: http://msdn.microsoft.com/en-us/sync/default.aspx
• Microsoft SQL Server 2008 Programmability– http://www.microsoft.com/sqlserver/2008/en/us/programmability.aspx
• Project Codename “Huron”– http://www.microsoft.com/azure/huron.mspx
• Personal Blog– http://aartemiou.blogspot.com
23- Flexible Data Synchronization with Microsoft Sync Framework -
Q & A