Batch calls

Deprecated

The Storm API client for .net has been tag:ed end of life and will be ceased to be updated and supported in roll out tests in an unspecified later date.

All Storm’s API’s moves to open API standards and swagger endpoints and these old clients with dependencies to 3rd party technologies or tools will stop being supported. No specific date in set yet.

When using batching you must first register your requests to the AccessClient and then process the requests to finally get the results.

This model works nicely with the WebForms page life cycle and automatically processes registered requests just before PreRenderComplete. This allows components to register requests on Page_Load and get the results in PreRenderComplete. If the component does not process PreRenderComplete you can always hook up on the dataReady event. When registering requests, the request is tagged with a unique key which is used when getting the result. (FELICA: Ska det vara på legacy sidan?)

Samlpe code AccessClient:

Copy
Copied
using(var client = new AccessClient())
{
   client.RegisterRequest("products", 
        new Expose.ListProducts2Request { set parameters });
   client.RegisterRequest("filters", 
        new Expose.ListProductFilters2Request { set parameters });
 
   client.ProcessRequests();
 
   ProductItemPagedList productList;
   FilterList filters = null;
 
   client.TryGet("products", out productList);
   client.TryGet("filters", out filters);
}

Sample code using repository (Enferno.Public.Web):

Copy
Copied
using(var batch = repository.GetBatch())
{
   batch.RegisterRequest("products", repository.Products.ListProductsRequest(...));
   batch.RegisterRequest("filters", repository.Products.ListProductFiltersRequest(...);
 
   batch.ProcessRequests();
 
   ProductItemPagedList productList;
   FilterList filters = null;
 
   batch.TryGet("products", out productList);
   batch.TryGet("filters", out filters);
}
Note

Batched requests are processed in parallel on the server and the results are guaranteed to be returned in the same order as the requests are passed in. However, if more than one request affect the same data there is no guarantee that the order of execution is according to the order of the requests. So if request2 is processed before request1 then the result for request1 will have the most recent data.