Understanding Synchronous and Asynchronous Execution of Triggered Tasks

When you run a Triggered Task, the request is synchronous by default. The Task responds with an HTTP response status code upon completion. 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.

For example, take the following Pipeline:

When you trigger the Task created from this Pipeline, for example from a browser, you receive an HTTP response status code on completion.

For example:

{ http_status_code: 200 }

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

If you want to make the Pipeline asynchronous, you can add a Snap with an unterminated output, as shown in the following example:

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 shown:

{ 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. 


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

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


The status code (405) as reflected on the browser (Postman):