13.5 Asynchronous Batch Operations
SData supports asynchronous batch operations.
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:
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):
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:
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.