Administering batch requests

Batch requests have special functionality for:

  • Specifying subrequest headers
  • Specifying behavior when a subrequest fails
  • Configuration of the maximum number of subrequests

Specifying subrequest headers

The following is an example of a batch request where each subrequest has a header that overrides the main request header.

{
  "requests": [
    {
      "method": "delete",
      "path": "/activities/xc:55",
      "headers": [
        {
          "name": "GW-Checksum",
          "value": "2"
        }
      ]
    },
    {
      "method": "delete",
      "path": "/activities/xc:57",
      "headers": [
        {
          "name": "GW-Checksum",
          "value": "4"
        }
      ]
    }
  ]
}

Specifying onFail behavior

The following is an example of a batch request that uses onFail to specify that if any of the subrequests fail, the remaining subrequests need to be skipped.

{
  "requests": [
    {
      "method": "patch",
      "path": "/activities/xc:93",
      "body": {
        "data": {
          "attributes": {
            "subject": "PATCH body 1"
          }
        }
      },
      "onFail": "abort"
    },
    {
      "method": "patch",
      "path": "/activities/xc:94",
      "body": {
        "data": {
          "attributes": {
            "subject": "PATCH body 2"
          }
        }
      },
      "onFail": "abort"
    },
    {
      "method": "patch",
      "path": "/activities/xc:95",
      "body": {
        "data": {
          "attributes": {
            "subject": "PATCH body 3"
          }
        }
      }
    }
  ]
}

Configuring the maximum number of subrequests

Batch requests are limited to a maximum number of subrequests. The maximum is specified by the MaximumAllowedNumberOfBatchSubRequests configuration parameter. In the base configuration, this parameter is set to 100. Batch requests with more than the maximum number of subrequests fail with a BadInputException.

The greater the number of subrequests in a batch request, the greater the chances that there will be a compromise in performance. A batch request with the maximum number of subrequests could result in a slow response, depending on what the maximum is and what those subrequests are doing.

You can increase the maximum number of subrequests to a value greater than 100. However, batch requests with a significantly large number of subrequests could have negative consequences, such as:

  • The request consuming a significant amount of service resources. This could include both memory and database resources.
  • The request taking so long to complete that it times out before a response can be provided to the caller.

Consequently, Guidewire recommends setting the maximum number of subrequests to the lowest value that is needed. If there is a legitimate business need to raise the maximum above 100, Guidewire recommends the limit be raised only as much as is absolutely necessary.

Also, be aware that batch requests are subject to any application server limitations around the maximum size of a request body. Thus, it is possible for a batch request to be too large to process, even if the number of subrequests is at or below the allowed maximum.