Previous Page Arrow Next Page Arrow

13.5 Asynchronous Batch Operations

SData supports asynchronous batch operations.

The schema MUST indicate if batching is supported in synchronous or asynchronous mode or in both modes, by means of the sme:batchingattribute.

The protocol is similar to the one used for asynchronous service operations.

A batch can be submitted asynchronously by adding a trackingID parameter to the URL. For example:

http://www.example.com/sdata/myApp/myContract/-/accounts/$batch?trackingID=abc42b0d-d110-4f5c-ac79-d3aa11bd20cb

The asynchronous execution acts as a normal asynchronous service request. The provider would send a response such as:

202 Accepted
Location: http://www.example.com/sdata/myApp/myContract/-/accounts/$batch?trackingID=abc42b0d-d110-4f5c-ac79-d3aa11bd20cb 

<?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 consumer can track the progress of the operation by sending a GET request on the tracking URL (Location HTTP header in the response above):

GET /sdata/myApp/myContract/-/accounts/$batch?trackingID=abc42b0d-d110-4f5c-ac79-d3aa11bd20cb

The provider responds with a 202 Accepted status as long as the operation is in progress. When the batch has been completely processed, the provider sends the normal 200 OK response with the response feed described in the section 13.4 Batch Responses.

The consumer MUST NOT forget to delete the batch resource by sending:

DELETE /sdata/myApp/myContract/-/accounts/$batch?trackingID=abc42b0d-d110-4f5c-ac79-d3aa11bd20cb
The asynchronous mode doesn't just help with performance, it also provides reliable posting because the presence of the trackingID parameter should make the POST operation idempotent (safe to be called several times). The provider should never create two batch jobs with the same trackingID.
SData providers MAY support the asynchronous mode for batch operations. If this mode is supported, the provider MUST use the protocol described above.

Previous Page Arrow Next Page Arrow