Docstoc

ADO Sync Services

Document Sample
ADO Sync Services Powered By Docstoc
					Name
Title
How caching reference data simplifies data access,
improves user performance
and reduces the workload of your server



How SQL Server Compact enables caching data on the client




How Sync Services for ADO.NET builds on your ADO.NET knowledge,
scales from simplistic, controlled scenarios to Service Oriented Architectures




Why one architecture doesn’t solve every problem
              • Very small (~1MB) embedded, in-proc database
              • Nice subset of SQL Server types and SQL dialect
What it is:   • Does not have: Stored Procs, Views, Xquery
                  • Why limit programming to T-SQL when you have managed code




Where it’s    • Mobile & Embedded devices
              • Windows Vista, Media Center PC, MSN Client,
                ZUNE, Windows Media Player, …
deployed      • Default Local/Client database offering in VS 2008



              •   Local online / offline cache
              •   Local, stand alone application database
Scenarios     •   Persistent data manager for In-Memory database
              •   Structured document format for custom apps
   Request made of the server
   DataAdapter.SelectCommand executed returning a result via DataSet
   Changes made in-memory, to the DataSet and sent back
   DataAdapter shreds changes to Insert, Update and Delete commands




                                                        SelectCommand
                                                        InsertCommand                Server
                               DataAdapter              UpdateCommand
                                                                        Connection
                                                                                      DB
Forms
                                                        DeleteCommand




   Communicate over services
   All operations round trip to the server
   Minimal leverage of the client – memory based operations
   Server deals with every level of detail
   Fragile to network instability
   Builds on DataAdapter
   Adds Incremental Commands
   Adds Conflict Commands
   Accepts and returns DataSets



                                              Select Incremental   Inserts

                                              Select Incremental Updates

                                             Select Incremental Deletes
                                            SelectCommand
                                             InsertCommand                      Server
                              DataAdapter
                              SyncAdapter   UpdateCommand
                                                                   Connection
                                                                                 DB
Forms
                                            DeleteCommand
                                            Select Conflict   Updated Rows…
                                            Select Conflict   Deleted Rows…
    Local storage to capture background sync operations
    Sync moves data between the local store and the remote service
    Application still works with data, but the data is now local
    App is now resilient to network instability



                                                           Select Incremental   Inserts

                                                          Select Incremental Updates

                                                           Select Incremental Deletes

                                                         InsertCommand                       Server
                                 SyncAdapter            UpdateCommand
                                                                                Connection
                                                                                              DB
Forms
                                                         DeleteCommand
                                                        Select Conflict    Updated Rows…
                                                         Select Conflict   Deleted Rows…




SQL Server
 Compact
   3.5
Offloads detailed questions to the client
Enables local processing, closer to the user




                  Enables offline scenarios
        Sync Designer configures:
              SyncAgent               Overall Orchestration
              ServerSyncProvider      Aggregates SyncAdapters
              SyncTables              Clients interest in what the server has to offer
              SyncGroup               Transaction Boundary for SyncTables
              ClientSyncProvider      Local Store Implementation
              Server Schema Changes   Saves as scripts for later execution
Data Forms


Data Access

                                      Server
         Client        SyncAgent   SyncProvider
      SyncProvider


SQL Server
 Compact   SyncGroup                                                     Server DB
   3.5                                 SyncAdapter
           SyncTable
2 models to choose from
  Data Synchronization – uploading local
  changes
     Sync Services bidirectional sync
     Simple; great for “well partitioned” data
     Enables local and remote processing of business rules,
     conflict detection / resolution
     Enabled by extending the designer code
  Logical Queuing
     Good when data is a “proposal to change”
     When “workflow” is required
     Works with existing service signature
Enabled by extending the Sync Designer
  Partial Public Class NorthwindCacheSyncAgent
     Public Overrides Sub OnInitialized()
        Me.Customers.SyncDirection = SyncDirection.Bidirectional


Conflicts can occur
    Not really any different then a connected system
    Client and Server Providers have Conflict events
  Partial Public Class NorthwindCacheServerSyncProvider
     Private Sub ApplyChangeFailedEvent(…) Handles Me.ApplyChangeFailed
        Dim clientChanges As DataTable = e.Conflict.ClientChange
        Dim serverChanges As DataTable = e.Conflict.ServerChange
        ' Code to resolve conflict
        e.Action = ApplyAction.RetryWithForceWrite


Business rules must be re-run
  Partial Public Class NorthwindCacheServerSyncProvider
     Private Sub ApplyingChangesEvent(…) Handles Me.ApplyingChanges
        Dim clientChanges As DataSet = e.Changes
        ' Code to revalidate business rules
Simple web communications to
more complex SOA scenarios
       Move the server components to another dll, hosted on a remote server
       Shim in a service (WCF) and a matching proxy




Data Forms


Data Access                          Transport

       Client                           ServerSyncProvider
                         SyncAgent
       SyncProvider
                                     Service
                                     Proxy            Service
SQL Server
 Compact
              SyncGroup
                                                                   Server DB
   3.5                                         SyncAdapter

             SyncTable
         What have we covered so far
Synchronized reference data via 2 Tier
  Utilized SQL Server Compact as our persistent
  cache
  SQLce database and schema auto created
Uploaded changes
  Added Validation and Biz logic
Moved to N Tier to leverage different
protocols and internet communications
  Assumes you can modify the signature of the
  service
  Changes sent in batches
Combining Sync Services and
Exisiting Services
                        Order
                   Processing
                        Logic      Orders
                                Proxy / Service
                                                    Fulfillment




Order Form
                                                   Accounting

                                     Sync
                                 Proxy / Service
             Local Changes
             Reference Data
                           Separate Save() from SendToService()
                           Use the local cache to store proposed changes



                             Order
                        Processing
                             Logic                    Orders
                                                   Proxy / Service
                                                                            Fulfillment



                           Network Resource
                              IsAvailable

Order Form
                                                                           Accounting
             Proposed
             Changes                                     Sync
                                                     Proxy / Service
               Local Changes
               Reference Data
    Hybrid of Sync Services and existing Services


Updated & new data kept in original location
   Database, Files
When changes are ready,
  mark them “good to go”
User can continue to edit, until delivery possible
   Outlook outbox model
When resource IsAvailable, send the data
   Package up the message from the source (database),
   and send
Works with existing services
How configuration & Performance gets better
 Best Performance and Productivity w/SQL Server 2008



Reduction in complexity
   Katmai: queries are simplified to retrieve changes from server
   Conflict detection functions provided

Database integration
   DBA turns on tracking per table via DDL or management tools
   Sync permission granted to each table
   System views provide management information about change tracking


Improves sync application and database performance
   Application: Sync calls optimized server sync functions
   Database: Changes are tracked on tables with minimal overhead (<10%)
   Database: Meta-data created for sync automatically purged by db engine
Sync Services Server Provider is
automatically configured
  No triggers or extra columns
  Bi-directional without custom code from Visual
  Studio
  Improved performance
VS 2005 SP1        Visual Studio 2008                          SQL Server 2008




   SQL Server            Sync Services       Visual Studio          SQL Server
   Compact               for ADO.NET         2008                   2008
   Edition               • Includes Agent,   • Sync Designer        • Includes SQL
   • Enable Desktop        SQLce Provider,   • Automates              Server 2008
     Clients               configurable        config of client &     provider
   • Easy to deploy        server provider     server               • Improves
     and redistribute    • Adds sync         • Generates code         performance
                           capabilities to     to query server      • Simplifies
                           familiar            for sync               development
                           ADO.NET syntax      information
SQL Server Compact
   Enabling SQL Server in your app
   Friction free deployment ~1mb dll’s
   SQL Server Compact 3.1 shipped w/VS 2005 SP1
   SQL Server Compact 3.5 shipping in VS 2008 as the local database
Sync Services for ADO.NET
   In Beta Now – ships with SQL Server Compact 3.5, VS 2008
   Works with VS 2005, .NET FX 2.0
   Builds on ADO.NET skills, Developer Productivity w/many features
   of Merge Replication
Visual Studio 2008
   RAD configuration of Sync Services and SQL Server Compact
SQL Server 2008
   Integrated change tracking making SQL Server 2008 your best
   server
Building resilient applications is the future,
not a stop gap
   It’s how all important resources are managed
Design your apps to cache from the
beginning
   When things are connected, they work great
   When “stuff” happens, your business continues
   to function
SQL Server Compact
www.Microsoft.com/SQL/Compact

SQL Server Compact Edition Q&A
Blogs.msdn.com/SqlServerCompact
Blogs.msdn.com/SteveLasker

Microsoft Synchronization Services for ADO.NET
www.SyncGuru.com
blogs.msdn.com/Synchronizer
© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market
     conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.
                                 MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

				
DOCUMENT INFO