ADF BC REST service - Batch Processing

JDev: 12.2.1.3.0
Source: GitHub

ADF BC REST services provide us with an interesting tool for bulk data processing - the batch process. The following article demonstrates how this feature can be quite helpful in reducing the volume of our code, and making our DML operations smooth.

As the name suggests, batch processing allows you to perform multiple DML operations in a single web service call.

A batch process is sent as a POST request, but there are 3 important ways a batch process differs from a standard POST request:

1) The base URL only goes till the rest URL pattern or the REST version.
2) The content-type header is "application/vnd.oracle.adf.batch+json".
3) Each DML operation in the batch is identified by a unique ID and an operation name ("create", "update" and "delete"). It is this ID which is referred to by the framework while reporting an error.


The body of the POST operation consists of an array of objects of the following structure:


* Each id uniquely identifies the operation.
* The path is relative to the base URL. This is appended to the base URL to get the complete REST path.
* Supported operations are "create", "update" and "delete".
* The payload is the request's body.

Only if all the operations are successful, the request gets committed. If not, then the entire batch is rolled back. Additionally, if there are any validation errors are raised by the ADF layer, the response lets us know the ID of the individual request which caused the failure.


**  An important note though: for errors thrown from the database (ORA errors) or for invalid REST paths, the actual error message is shown and no information is provided on which operation failed.

For a successful batch operation, the individual payloads are returned in the response body (same as in a regular POST request).


So to quickly summarize its top advantages:

1) Single REST call.
2) Mixing various operations ("create", "update" and "delete").
3) Reduce volume of front-end code.
4) All or none - either all go in and get committed, or else the entire operation is rolled back.
5) Almost effectively letting the front-end application know which particular operation failed.

** Refer to json folder in GitHub for sample payloads.

Cheers!

Comments