Class AdbTransactionActionWorker
A worker which creates and opens an AdbKeepOpenConnection and a single local AdbTransaction, runs a user supplied delegate that performs database commands inside the transaction, commits or rolls back the transaction on success or failure, and finally disposes the transaction and connection. The delegate typically creates Adb child database workers that automatically participates in the transaction, which will be rolled back if any of these child workers (or the callback) fails.
This construct is very useful for running multiple database commands and database workers inside a single transaction, and have them collectively either committed or rolled back, while correctly handling any exceptions that might occur.
As with any transaction, keep the duration of the work short, where possible moving work outside the transaction (i.e. outside this worker), and avoiding delays inside it. Furthermore, do ensure that the volume of modified data does not exceed the database server's capacity to handle it, as it will accumulate until the final commit or roll-back.
AddStartingCallback(Func<WorkerBase, Task<ProgressStatus>>) can be used. Note however, that the connection and transaction are only created and opened if and when the worker is run.
See AdbTransactionActionWorker Example for how to use this worker.
Inheritance
Implements
Inherited Members
Namespace: actionETL.Adb
Assembly: actionETL.dll
Syntax
public class AdbTransactionActionWorker : WorkerBase<AdbTransactionActionWorker>, IDisposeOnFinished
Constructors
AdbTransactionActionWorker(WorkerParent, String, AdbKeepOpenConnectionBuilder, Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder>)
Initializes a new instance of the AdbTransactionActionWorker
worker that
creates and opens an AdbKeepOpenConnection and a single local
AdbTransaction, runs a user supplied delegate that performs database commands inside the
transaction (often via creating child workers), commits or rolls back the transaction on success or failure,
and finally disposes the transaction and connection.
Declaration
public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder> action)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
AdbKeepOpenConnectionBuilder | adbKeepOpenConnectionBuilder | A keep-open connection builder. |
Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder> | action | The synchronous action to execute, optionally creating child workers. It receives the worker itself and
|
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
AdbTransactionActionWorker(WorkerParent, String, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus>)
Initializes a new instance of the AdbTransactionActionWorker
worker that
creates and opens an AdbKeepOpenConnection and a single local
AdbTransaction, runs a user supplied delegate that performs database commands inside the
transaction (often via creating child workers), commits or rolls back the transaction on success or failure,
and finally disposes the transaction and connection.
Declaration
public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus> func)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
AdbKeepOpenConnectionBuilder | adbKeepOpenConnectionBuilder | A keep-open connection builder. |
Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus> | func | The synchronous function to execute, optionally creating child workers. It receives the worker itself and
|
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
AdbTransactionActionWorker(WorkerParent, String, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>>)
Initializes a new instance of the AdbTransactionActionWorker
worker that
creates and opens an AdbKeepOpenConnection and a single local
AdbTransaction, runs a user supplied delegate that performs database commands inside the
transaction (often via creating child workers), commits or rolls back the transaction on success or failure,
and finally disposes the transaction and connection.
Declaration
public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>> funcAsync)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
AdbKeepOpenConnectionBuilder | adbKeepOpenConnectionBuilder | A keep-open connection builder. |
Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>> | funcAsync | The asynchronous function to execute, optionally creating child workers. It receives the worker itself and
|
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
AdbTransactionActionWorker(WorkerParent, String, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task>)
Initializes a new instance of the AdbTransactionActionWorker
worker that
creates and opens an AdbKeepOpenConnection and a single local
AdbTransaction, runs a user supplied delegate that performs database commands inside the
transaction (often via creating child workers), commits or rolls back the transaction on success or failure,
and finally disposes the transaction and connection.
Declaration
public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task> actionAsync)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
AdbKeepOpenConnectionBuilder | adbKeepOpenConnectionBuilder | A keep-open connection builder. |
Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task> | actionAsync | The asynchronous action to execute, optionally creating child workers. It receives the worker itself and
|
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
AdbTransactionActionWorker(WorkerParent, String, Func<Boolean>, AdbKeepOpenConnectionBuilder, Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder>)
Initializes a new instance of the AdbTransactionActionWorker
worker that
creates and opens an AdbKeepOpenConnection and a single local
AdbTransaction, runs a user supplied delegate that performs database commands inside the
transaction (often via creating child workers), commits or rolls back the transaction on success or failure,
and finally disposes the transaction and connection.
Declaration
public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder> action)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
AdbKeepOpenConnectionBuilder | adbKeepOpenConnectionBuilder | A keep-open connection builder. |
Action<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder> | action | The synchronous action to execute, optionally creating child workers. It receives the worker itself and
|
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
AdbTransactionActionWorker(WorkerParent, String, Func<Boolean>, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus>)
Initializes a new instance of the AdbTransactionActionWorker
worker that
creates and opens an AdbKeepOpenConnection and a single local
AdbTransaction, runs a user supplied delegate that performs database commands inside the
transaction (often via creating child workers), commits or rolls back the transaction on success or failure,
and finally disposes the transaction and connection.
Declaration
public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus> func)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
AdbKeepOpenConnectionBuilder | adbKeepOpenConnectionBuilder | A keep-open connection builder. |
Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, OutcomeStatus> | func | The synchronous function to execute, optionally creating child workers. It receives the worker itself and
|
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
AdbTransactionActionWorker(WorkerParent, String, Func<Boolean>, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>>)
Initializes a new instance of the AdbTransactionActionWorker
worker that
creates and opens an AdbKeepOpenConnection and a single local
AdbTransaction, runs a user supplied delegate that performs database commands inside the
transaction (often via creating child workers), commits or rolls back the transaction on success or failure,
and finally disposes the transaction and connection.
Declaration
public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>> funcAsync)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
AdbKeepOpenConnectionBuilder | adbKeepOpenConnectionBuilder | A keep-open connection builder. |
Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task<OutcomeStatus>> | funcAsync | The asynchronous function to execute, optionally creating child workers. It receives the worker itself and
|
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
AdbTransactionActionWorker(WorkerParent, String, Func<Boolean>, AdbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task>)
Initializes a new instance of the AdbTransactionActionWorker
worker that
creates and opens an AdbKeepOpenConnection and a single local
AdbTransaction, runs a user supplied delegate that performs database commands inside the
transaction (often via creating child workers), commits or rolls back the transaction on success or failure,
and finally disposes the transaction and connection.
Declaration
public AdbTransactionActionWorker(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, AdbKeepOpenConnectionBuilder adbKeepOpenConnectionBuilder, Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task> actionAsync)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
AdbKeepOpenConnectionBuilder | adbKeepOpenConnectionBuilder | A keep-open connection builder. |
Func<AdbTransactionActionWorker, AdbKeepOpenConnectionBuilder, Task> | actionAsync | The asynchronous action to execute, optionally creating child workers. It receives the worker itself and
|
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
Methods
RunAsync()
This method can be overridden to add custom functionality to the derived worker that runs before
and after the row processing, but after
AddStartingCallback(Func<WorkerBase, Task<ProgressStatus>>) and before
AddCompletedCallback(Func<WorkerBase, OutcomeStatus, Task<OutcomeStatus>>)
callbacks. In this case, the base class base.RunAsync()
must be called for the worker to function correctly.
Typically, this worker is used without overriding this method.
Declaration
protected override Task<OutcomeStatus> RunAsync()
Returns
Type | Description |
---|---|
Task<OutcomeStatus> | A |