Use the query action to monitor the status of an execution.
[
{
"name": "query",
"script": "stepTypeCallback",
"config": {
"callbackAction": "query",
"callbackToken": "%{param:callbackToken}"
},
"next": false
}
]
The query action requires the token property. This would typically be read from a passed-in parameter.
The query action returns in <return> an object of the form:
{
"callbackStatus": "status",
"callbackData": {
// Response data
}
]The data property will contain the createData object saved when the callback was first created.
The status notFound is used if the token cannot be found. This could mean that it has timed out and the record of the process has now been deleted, or it could be that the token is wrong.
If you want to return data with the query, follow the query with a step that provides more information. For example, assuming that you were recording progress in the data area "progress" (see Returning progress and intermediate results), you could add this data to the query response using something like this.
[
{
"name": "query",
"script": "stepTypeCallback",
"config": {
"callbackAction": "query",
"callbackToken": "%{param:callbackToken}",
},
"next": {
"progress": "queryProgress",
"complete": "queryProgress",
"*": false
}
},
{
"name": "queryProgress",
"script": "stepTypeEvaluate",
"config": {
"data": {
"callback": "%{attr:callbackData}",
"progress": "%{data:progress}"
},
"script": [
"(function(){",
"data.callback.callbackData.progress = data.progress;",
"return data.callbackData;",
"})()"
]
},
"next": false
}
]
When the status is progress or complete, pass control to the evaluate step. The evaluate step merges the progress data into the response object within the callback.