Skip to main content

HTTP Poll

The HTTP_POLL is a conductor task used to invoke HTTP API until the specified condition matches.

Definitions

    {
"name": "http_poll_task",
"taskReferenceName": "http_poll_task_ref",
"type": "HTTP_POLL",
"inputParameters": {
"http_request": {
"uri": "https://orkes-api-tester.orkesconductor.com/get",
"method": "GET",
"connectionTimeOut": 3000,
"readTimeOut": 3000,
"accept": "application/json",
"contentType": "application/json",
"terminationCondition": "1",
"pollingInterval": "60",
"pollingStrategy": "FIXED"
}
}
}

Input Parameters

AttributeDescription
terminationConditionSpecifies the condition to be evaluated after every HTTP API invocation. If the condition is evaluated as true, the task will be marked as completed. On the other hand, if the condition is evaluated as false, the conductor will schedule the next poll according to the configurations (pollingInterval & pollingStrategy). By default, this value is set to true.
Note: While writing the termination condition,
  • It can be parameterized.
  • In order to use the current http poll as input to the condition, a $ needs to be prefixed. For example, $.output.status
pollingIntervalSpecify the time duration in seconds between each HTTP invocation.
pollingStrategyIt can take any of the following values:
  • FIXED - The duration between each HTTP API invocation will be fixed.
  • LINEAR_BACKOFF - The duration between each HTTP API invocation will be calculated by multiplying the poll count with pollingInterval. Note that the poll count is the incremental value based on each invocation.
  • EXPONENTIAL_BACKOFF - The duration between each HTTP API invocation will be calculated by multiplying poll count with 2 base exponential of pollingInterval.

Apart from the above parameters, ensure that the following basic parameters for an HTTP task are also provided.


AttributeDescription
uriProvide the Uniform Resource Identifier (URI) for the service. It can be partial when using vipAddress or else it indicates the server address.
methodIndicates the required action to be performed on the source. It can be GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS or TRACE.
acceptProvide the accept header as required by the server. By default, it is set to application/json.
contentTypeProvide the content type for the server. The supported types are text/plain, text/html, and application/json. By default, it is set to application/json.
headersIndicate a map of additional http headers to be sent along with the request.
bodyIndicates the request body.
asyncCompleteIf set, the task remains in the IN_PROGRESS state even after the execution. An external event (Task Update API or Event handler) is expected to mark the task as completed.
connectionTimeOutSet the connection timeout in milliseconds. If set to 0, it is equivalent to infinity. By default, the value is set to 100.
readTimeOutSet the read timeout in milliseconds. If set to 0, it is equivalent to infinity. By default, the value is set to 150.
cacheConfigEnabling this option allows saving the cache output of the task. On enabling you can provide the following parameters:
  • TTL (in seconds) - Provide the time to live in seconds.You can also pass this parameter as variables.
  • Cache Key - Provide the cache key, which is a string with parameter substitution based on the task input. You can also pass this parameter as variables.

Output Parameters

AttributeDescription
responseJSON body containing the response if present.
headersResponse Headers.
statusCodeHTTP Status Code.
reasonPhraseHTTP Status Code's reason phrase.

Examples



  1. Add task type HTTP Poll.
  2. Configure the Polling endpoint.
  3. Configure the interval.

Adding HTTP Poll Task

Sample Workflow

Let’s see an example workflow:

    {
"name": "your_workflow_name",
"description": "Sample workflow to get started with HTTP POLL task.",
"tasks": [
{
"name": "example",
"taskReferenceName": "example",
"inputParameters": {
"http_request": {
"uri": "https://jsonplaceholder.typicode.com/posts/1",
"method": "GET",
"terminationCondition": "$.output.body.length > 10 ? true : false;",
"pollingInterval": "60",
"pollingStrategy": "FIXED"
}
},
"type": "HTTP_POLL"
}
]
}

So, here the input parameters for the HTTP_POLL task are defined as follows:

      "terminationCondition": "$.output.body.length > 10 ? true : false;",
"pollingInterval": "60",
"pollingStrategy": "FIXED"

The above configuration defines that the Conductor will invoke the HTTP API every 60 seconds until the jsonplaceholder gives the output that is longer than 10 characters.


note

Current invocation output can be referred to using $.output. Similarly, previous tasks' output can also be referred to using $.task_ref_name.output.