Previous Page Arrow Next Page Arrow

5.2 Querying Source Synchronization Feed

In a second step, the synchronization engine queries the source feed. This can be a rather expensive operation as the source provider needs to find the resources that have a state that is more recent than the target digest, and the context of the source feed must be maintained across several calls because the source feed may be paged. So, SData handles this as an asynchronous POST operation that creates a source feed resource:

POST /sdata/myApp1/myContract/-/accounts/$syncSource?trackingID=DD052E5C-BFAD-4ffa-8D54-D696E4959497&runName=Full%20CRM%20to%20ERP&runStamp=2009-10-14T08:51:02 HTTP/1.1
Content-Type: application/atom+xml; type=entry

<entry xmlns="http://www.w3.org/2005/Atom">
  <id>http://www.example.com/sdata/myApp2/myContract/-/accounts/$syncDigest</id>
  <title>Synchronization digest</title>
  <updated>2008-03-31T13:46:45Z</updated>
  <link rel="self" type="application/atom+xml; type=entry" title="Refresh" 
        href="http://www.example.com/sdata/myApp2/myContract/-/accounts/$syncDigest" />
  <payload xmlns="http://schemas.sage.com/sdata/2008/1">
    <digest xmlns="http://schemas.sage.com/sdata/sync/2008/1">
      <origin>http://www.example.com/sdata/myApp1/myContract/-/accounts</origin>
      <digestEntry>
        <endpoint>http://www.example.com/sdata/myApp1/myContract/-/accounts</endpoint>
        <tick>5</tick>
        <stamp>2008-10-30T14:52:03.281Z</stamp>
        <conflictPriority>2</conflictPriority>
      </digestEntry>
      <digestEntry>
        <endpoint>http://www.example.com/sdata/myApp2/myContract/-/accounts</endpoint>
        <tick>11</tick>
        <stamp>2008-10-30T13:46:45Z</stamp>
        <conflictPriority>1</conflictPriority>
      </digestEntry>
      <digestEntry>
        <endpoint>http://www.example.com/sdata/sageApp3/test/-/accounts</endpoint>
        <tick>8</tick>
        <stamp>2008-10-30T12:40:25Z</stamp>
        <conflictPriority>3</conflictPriority>
      </digestEntry>
    </digest>
  </payload>
</entry>

Like any asynchronous SData operation, this request will return a 202 Accepted response until the source feed is ready:

202 Accepted
Location: http://www.example.com/sdata/myApp1/myContract/-/accounts/$syncSource('DD052E5C-BFAD-4ffa-8D54-D696E4959497')
 
<?xml version="1.0" encoding="utf-8"?>
<tracking xmlns="http://schemas.sage.com/sdata/2008">
  <phase>Initialization</phase>
  <phaseDetail>Starting thread</phaseDetail>
  <progress>0.0</progress>
  <elapsedSeconds>0</elapsedSeconds>
  <remainingSeconds>7</remainingSeconds>
  <pollingMillis>500</pollingMillis>
</tracking>

The engine will perform a GET on the Location URL (http://www.example.com/sdata/myApp1/myContract/-/accounts/$syncSource(‘DD052E5C-BFAD-4ffa-8D54-D696E4959497’)) until it gets a 200 HTTP status. At this time, it will get a response like:

200 OK
Content-Type: application/atom+xml; type=feed

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:sdata="http://schemas.sage.com/sdata/2008/1">

  <title>Account synchronization feed DD052E5C-BFAD-4ffa-8D54-D696E4959497</title>
  <id>http://www.example.com/sdata/myApp1/myContract/-/accounts/$syncSource('DD052E5C-BFAD-4ffa-8D54-D696E4959497')</id>
  <updated>2008-03-31T13:46:45Z</updated>
  <link rel="self" type="application/atom+xml; type=feed" title="Refresh" 
        href="http://www.example.com/sdata/myApp1/myContract/-/accounts/$syncSource('DD052E5C-BFAD-4ffa-8D54-D696E4959497')" />
  <link rel="first" type="application/atom+xml; type=feed" title="First Page" 
        href="http://www.example.com/sdata/myApp1/myContract/-/accounts/$syncSource('DD052E5C-BFAD-4ffa-8D54-D696E4959497')" />
  <link rel="next" type="application/atom+xml; type=feed" title="NextPage" 
        href="http://www.example.com/sdata/myApp1/myContract/-/accounts/$syncSource('DD052E5C-BFAD-4ffa-8D54-D696E4959497')
?startIndex=11&amp;count=10" />

  <syncMode xmlns="http://schemas.sage.com/sdata/sync/2008/1">catchUp</syncMode>

  <!-- Digest -->
  <digest xmlns="http://schemas.sage.com/sdata/sync/2008/1">
    <origin>http://www.example.com/sdata/myApp1/myContract/-/accounts</origin>
    <digestEntry>
      <endpoint>http://www.example.com/sdata/myApp1/myContract/-/accounts</endpoint>
      <tick>6</tick>
      <stamp>2008-10-30T17:23:08Z</stamp>
      <conflictPriority>2</conflictPriority>
    </digestEntry>
    <digestEntry>
      <endpoint>http://www.example.com/sdata/myApp2/myContract/-/accounts</endpoint>
      <tick>10</tick>
      <stamp>2008-10-30T12:16:51Z</stamp>
      <conflictPriority>1</conflictPriority>
    </digestEntry>
    <digestEntry>
      <endpoint>http://www.example.com/sdata/sageApp3/test/-/accounts</endpoint>
      <tick>10</tick>
      <stamp>2008-10-30T16:47:03Z</stamp>
      <conflictPriority>3</conflictPriority>
    </digestEntry>
   </digest>

  <!-- Entry -->
  <entry>
    <id/>
    <title/>
    <updated>2008-10-30T14:55:43.281Z</updated>
    <content/>

    <!-- Per-Resource Synchronization State -->
    <syncState xmlns="http://schemas.sage.com/sdata/sync/2008/1">
      <endpoint>http://www.example.com/sdata/myApp1/myContract/-/accounts</endpoint>
      <tick>5</tick>
      <stamp>2008-10-30T14:55:43.281Z</stamp>
    </syncState>

    <!-- XML payload -->
    <payload xmlns="http://schemas.sage.com/sdata/2008/1">
      <account sdata:uuid="74926A0D-D2C0-4daa-9986-47C833691569" xmlns="http://schemas.sage.com/myContract">
        <name>Natural Goods Ltd.</name>
        <!-- more account data -->
      </account>
    </payload>

    </payload>
  </entry>

  <!-- Entry -->
  <entry>
    <id>http://www.example.com/sdata/myApp1/myContract/-/accounts('23552')</id>
    <title>Account Chemical Bros</title>
    <updated>2008-05-25T13:27:19.207Z</updated>
    <content>Account Chemical Bros</content>

    <!-- Per-Resource Synchronization State -->
    <syncState xmlns="http://schemas.sage.com/sdata/sync/2008/1">
      <endpoint>http://www.example.com/sdata/sageApp3/test/-/accounts</endpoint>
      <tick>8</tick>
      <stamp>2008-10-30T13:27:19.207Z</stamp>
    </syncState>

    <!-- XML payload -->
    <payload xmlns="http://schemas.sage.com/sdata/2008/1">
      <account sdata:uuid="C4411795-9943-4cf4-8705-51A74C9F0ACC" xmlns="http://schemas.sage.com/myContract">
        <name>Chemical Brothers Inc.</name>
        <!-- more account data -->
      </account>
    </payload>

  </entry>

  <!-- ... more entries ... -->
</feed>
A provider exposing a $syncSource URL for resource kind MUST support asynchronous calls as well as the sequential paging mechanism for retrieving the operation results.

Previous Page Arrow Next Page Arrow