Skip to end of banner
Go to start of banner

ForEach

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

The ForEach Snap is being phased out in favor of the Pipeline Execute Snap.



Snap type:

Flow

 

Description:

This Snap can be used to invoke a new pipeline for each of the incoming documents. The incoming document can hold the pipeline parameters that are required to run the pipeline. 

This Snap is being phased out in favour of the Pipeline Execute Snap. Pipeline Execute will execute the child in preview mode.

Prerequisites:

None

 

Support and limitations:

 

Account: 

Accounts are not used with this Snap.

 

Views:
InputThis Snap has at most one document input view that could carry pipeline parameters
OutputThis Snap has exactly one document output view that will hold the pipeline run information. The input document is passed through to the output view under the key "data".
ErrorThis Snap has at most one document error view and produces zero or more documents in the view.

 
Note: If the pipeline invoked by the ForEach Snap exits with either STOPPED or FAILED state, these messages will flow to the error view if it is exposed. If the error view on the Snap is not exposed, the ForEach Snap will fail.

 

The ForEach Snap is being phased out in favor of the Pipeline Execute Snap.

Settings

Label

 

Required. The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline.

Pipeline


 

Required. The pipeline that should be executed for each incoming document.

Default value: Null 

Snaplex


Snaplex where the pipeline will be run. If this field is left empty, the pipeline will be run on the runtime path where the ForEach Snap is executing.

Default value: [None]

 

Execution mode


Required. Execution mode for running the pipeline. The options available include:

  • SYNCHRONOUS
  • FIRE_AND_FORGET

If execution mode is set to SYNCHRONOUS mode, the ForEach Snap will wait for each pipeline execution to complete before reading the next document from the input view. In case of FIRE_AND_FORGET mode, pipeline execution is scheduled and the pipeline run id is written to the output view and ForEach Snap will proceed with next input.

Default value: SYNCHRONOUS

 

Batch size for synchronous mode


When Synchronous mode is selected, pipeline execution will be carried out in batch. When the batch size is reached, this Snap will wait for all the executions in the batch to complete before proceeding.
Default value: 1
 

Pipeline parameters


Pipeline parameters that should be used for executing the pipeline can be configured in this property. The Parameter name is the name of the parameter that should be used while executing the pipeline. You can select the pipeline parameters defined for the pipeline selected in the Pipeline field. The Parameter value is the expression property that can be configured as an expression based on incoming document or can be a constant. If it is configured as an expression based on the incoming document, each incoming document will be evaluated for the given expression and the value is set as the parameter value for the parameter name while invoking the pipeline.

Default value: [None]

 

Maximum instances

Required. In the SYNCHRONOUS mode, this property is the maximum number of times the ForEach Snap can call its own pipeline recursively. In this mode, you should have a logic built within the pipeline so that the pipeline execution completes gracefully before the number of instances reaches to the value of this property. Otherwise, the Snap will throw an error. The last instance in the nested pipelines will show an error "The maximum number of recurring pipeline instances has reached in the synchronous mode, Maximum instances: ...", and the rest will show "Error occurred while waiting for the pipeline to complete the execution".

In the FIRE_AND_FORGET mode, this property is the maximum number of the instances of which the recurring pipelines can run at any given time. Therefore, in the mode, the pipeline runs forever recursively while the number of the pipeline instances in progress is limited to the value of this property. 


The value for Maximum instances is limited to a maximum of 100. A value higher than 100 will automatically be limited down to 100 during pipeline execution.

Default value: 50

 

Execute during preview


Executes the Snap during a pipeline Save operation so that the output view can produce the preview data.

Default value: Not selected

 

 

When using a ForEach Snap, the state of the child pipeline configured in the pipeline parameter of the Snap is represented in the $state value, which is the default element in the output document. This can be very useful for flow Snaps such as Filter (expression example: $state == "COMPLETED").

Examples


The following pipelines show how to use the ForEach Snap to write multiple files. The first pipeline reads a JSON document that contains a list of zip codes and Snaplexes. The ForEach Snap then calls the second pipeline three times, once for each zip code entry. It uses the cityzipcode parameter to request the current weather from a public Web Service, adds a timestamp, and then writes a file using the zip code as the file name.


 

 

 

 

 

Pipeline Downloads

 

Snap History

January 2014

  • Initial release of this Snap.
  • No labels