Synchronous and asynchronous Triggered Task execution

When you run a Triggered Task, the request is synchronous by default, unless it is called using the Snaplex/Alternate URL in the Task Details page (also known as a Groundplex trigger).

Calling the task through the Cloud URL on the Task Details page (also known as the cloud trigger), makes the call synchronous, irrespective of whether the associated pipeline has an output view open or not.  However, since Groundplex triggers are asynchronous, they require a pipeline's output view open to wait for the output to be sent in the response.

The Task responds with an HTTP response status code upon completion.

For example, take the following pipeline: Example of Triggered Task Sync

When you trigger the task created from this pipeline, for example from a browser, you receive an HTTP response status code on completion, such as:

{ http_status_code: 200 }

The request waits until the pipeline execution has completed before displaying this message.

However, if the pipeline has a single, unterminated Snap providing output, then the output from that Snap is provided as the response to the request. This behavior lets the developer make the pipeline asynchronous, in that the response is written back to the user. If you want to make the pipeline asynchronous, you can add a Snap with an unterminated output, as shown in the following example:

Example of Triggered Task Async

Now when you trigger the Task created from this pipeline, the output from the response Generator Snap is provided almost as soon as the pipeline executions starts.

In this case, a JSON Generator responds with the message:{ msg: "Started Ok", http_status_code: 200 }

The net effect of which is that the Pipeline execution behaves asynchronously.

Passing the execution status code through binary header properties of the JSON Formatter Snap

You can view the Task status in the browser, the same as on the output view of the pipeline. In this pipeline, the execution status is routed to the error view, which is redirected to reflect in the browser using the Binary Header Properties of the JSON Formatter Snap.
Note: The workaround of using Binary Header properties is mainly useful when you want to view the exact execution status of the Triggered Task, which might not be consistent with the status code otherwise reflected on the browser.

Pipeline of Triggered Task

The status code (405) as retrieved from the pipeline is mapped to the response:

Mapper Snap Settings

The JSON Formatter Snap passes the actual status code to the browser via the Binary Header Properties:

JSON Formatter Snap Settings