Transactions can include inner flows. If a transactional Stage executes an inner flow, it automatically becomes a part of the outer transaction and can use its shared resource.
When the outer flow starts the transaction and then invokes an inner flow, the inner flow does not close the transaction. The transaction is closed by the outer flow.
The transaction ends after the last Stage marked as a transaction. A transaction's behavior during an iteration is based on marking of the Stages within the iteration.
One Commit Example
The Load Stage inside the loop is transactional. The Source Stage before the loop can be transactional or not. The commit is performed at the end of the data set.
Commit per Iteration Example
If a non-transactional Stage is added at the end of the loop, the commit is performed per each iteration.
Batch Commit Example
When the data set is very big (for example, 1M records) and a commit is required every X records, you can perform the commit per batch.
The following example shows how to perform a commit every 5 records using a Stage Condition and the JavaScript Actor.
Writing the following code, Stage 1 is only reached every fifth record:
var i = contextLoop.index();
(i+1)%5 == 0;
The transaction is then committed since Stage 1 is not marked as transactional and a new transaction begins.
Commit During an Iteration Example
The following is an example of a transaction's behavior in the loop when not all Stages inside the loop are transactional.
When an Error Handler is defined on the transactional Stage of the flow and it catches an error, the Error Handler can either be true to continue the flow or false to stop the flow. If the Error Handler returns false, the transaction ends with a rollback and the flow's execution stops. The error message displays the failure reason.
When the flow is split due to Stage conditions, the transaction can be defined for only some branches. For example, for an IF-ELSE condition, you can define that the transaction occurs only when the condition is true.
In the example below, the transaction starts in Stage B1 if the condition is true and ends after the completion of Stage C1. If the condition is false, there is no transaction in this flow.
In the second example, the transaction starts in Stage A. If the condition is true, the transaction ends after the completion of Stage C1. If the condition is false, the transaction ends at the end of Stage A.
Note that if there are several conditions or too many parallel branches in the flow, it is not recommended to use the Transactions mechanism across the branches.
Fabric Interfaces used in a Broadway flow can be shared or non-shared during the transaction.
In a Broadway flow window, a Transaction is marked by blue diagonal lines in the Stage's background and can span across several Stages.
To mark a Stage, click > Transaction. | To unmark a Stage, uncheck Transaction. |
Transactions can include inner flows. If a transactional Stage executes an inner flow, it automatically becomes a part of the outer transaction and can use its shared resource.
When the outer flow starts the transaction and then invokes an inner flow, the inner flow does not close the transaction. The transaction is closed by the outer flow.
The transaction ends after the last Stage marked as a transaction. A transaction's behavior during an iteration is based on marking of the Stages within the iteration.
One Commit Example
The Load Stage inside the loop is transactional. The Source Stage before the loop can be transactional or not. The commit is performed at the end of the data set.
Commit per Iteration Example
If a non-transactional Stage is added at the end of the loop, the commit is performed per each iteration.
Batch Commit Example
When the data set is very big (for example, 1M records) and a commit is required every X records, you can perform the commit per batch.
The following example shows how to perform a commit every 5 records using a Stage Condition and the JavaScript Actor.
Writing the following code, Stage 1 is only reached every fifth record:
var i = contextLoop.index();
(i+1)%5 == 0;
The transaction is then committed since Stage 1 is not marked as transactional and a new transaction begins.
Commit During an Iteration Example
The following is an example of a transaction's behavior in the loop when not all Stages inside the loop are transactional.
When an Error Handler is defined on the transactional Stage of the flow and it catches an error, the Error Handler can either be true to continue the flow or false to stop the flow. If the Error Handler returns false, the transaction ends with a rollback and the flow's execution stops. The error message displays the failure reason.
When the flow is split due to Stage conditions, the transaction can be defined for only some branches. For example, for an IF-ELSE condition, you can define that the transaction occurs only when the condition is true.
In the example below, the transaction starts in Stage B1 if the condition is true and ends after the completion of Stage C1. If the condition is false, there is no transaction in this flow.
In the second example, the transaction starts in Stage A. If the condition is true, the transaction ends after the completion of Stage C1. If the condition is false, the transaction ends at the end of Stage A.
Note that if there are several conditions or too many parallel branches in the flow, it is not recommended to use the Transactions mechanism across the branches.
Fabric Interfaces used in a Broadway flow can be shared or non-shared during the transaction.
In a Broadway flow window, a Transaction is marked by blue diagonal lines in the Stage's background and can span across several Stages.
To mark a Stage, click > Transaction. | To unmark a Stage, uncheck Transaction. |