Appearance
Batch Invocation
Introduction
It is possible to invoke an endpoint multiple times by using AireGlu's, asynchronous, batch processing functionality.
Access to this feature
Your tenant/username must be added to the ALLOWED_ASYNC_USERS
environment variable, you can add multiple users as a semicolon separated list.
How to invoke
Within your endpoint, add a HTTP Request Task. Make a POST request to the AireGlu Async Service - https://my-async.aireglu.com/Api/batch/{username}/{endpointName}/{environmentOrVersion}
The request body is a JSON object containing:
- the name of the callback endpoint to be invoked
request
array containing the required input to be passed into the batched endpoint invocations- environment or version of the callback endpoint
With a valid payload, the Async Api Endpoint will respond with a 202 Accepted
.
How authentication works
The endpoint to be invoked via batch, should be authenticated as you would normally for any other endpoint. The callback endpoint will be run by the batch functionality regardless of its authentication status, however, it should have authentication set so that it is protected from someone running it directly.
How will I monitor the requests?
Usage data will be populated but it will be very difficult to follow. We strongly recommend ensuring that debug mode is turned off for the batch invoke and callback endpoints to minimise the amount of usage data (transaction data) stored when an endpoint is batch-invoked. The callback endpoint can be used to collect information about what the outcome of each invocation was. When calling the Async API you have the option to supply a batch transaction id (if none is supplied an id is automatically generated), the transaction id is made available in the input of the callback endpoint.
Example endpoint definitions
Here is an example endpoint definition that you can use to experiment with.
Batch endpoint
Versions:
- Input:
Method: POST
InputMode: JSON
InputSource: Body
Schema: >-
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "",
"type": "object",
"properties": {
"test": {
"type": "string",
"minLength": 1
}
},
"required": [
"test"
]
}
XmlSchemas:
ErrorEmail: ''
StopOnTaskFailure: true
Tasks:
- Behaviour: Response
RequestContext:
ResponseHandlerContext:
EmailContext:
FaxContext:
MeshContext:
SmsContext:
JobContext:
ResponseContext:
OutputMode: JSON
MapType: Path
XsltParameters: []
StatusCode: 200
RetainStatusCode: false
Template: >-
{
"test": "--*test*--"
}
Paths:
test: $.test
PathOrigins: {}
Functions: {}
FunctionLocations:
RedirectContext:
MappingContext:
PdfContext:
AdapterContext:
SftpContext:
JwtContext:
Tests: []
Filters: []
Label: ''
DataOrigin: -1
UseCRLFLineEndings: false
AuthenticationContexts: []
Version: 1
Active: true
PersistTransactionData: false
Name: batch-test
Environments:
Staging: 1
Production: 1
Callback endpoint
Versions:
- Input: >-
{
"success": true,
"errors": [],
"originalInput": {},
"endpointOutput": {}
}
Method: POST
InputMode: Callback
InputSource: Body
Schema: >-
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "",
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"errors": {
"type": "array",
"items": {
"type": "string"
}
},
"originalInput": {
"type": "object",
"properties": {},
"required": []
},
"endpointOutput": {
"type": "object",
"properties": {},
"required": []
}
},
"required": [
"success",
"originalInput"
]
}
XmlSchemas:
ErrorEmail: ''
StopOnTaskFailure: true
Tasks:
- Behaviour: Response
RequestContext:
ResponseHandlerContext:
EmailContext:
FaxContext:
MeshContext:
SmsContext:
JobContext:
ResponseContext:
OutputMode: JSON
MapType: Path
XsltParameters: []
StatusCode: 200
RetainStatusCode: false
Template: >-
{
"success": "--*success*--"
}
Paths:
success: $.success
PathOrigins: {}
Functions: {}
FunctionLocations:
RedirectContext:
MappingContext:
PdfContext:
AdapterContext:
SftpContext:
JwtContext:
Tests: []
Filters: []
Label: ''
DataOrigin: -1
UseCRLFLineEndings: false
AuthenticationContexts: []
Version: 1
Active: true
PersistTransactionData: false
Name: async-callback-test
Environments:
Staging: 1
Production: 1