Package com.axelor.db
Class ParallelTransactionExecutor
java.lang.Object
com.axelor.db.ParallelTransactionExecutor
Executes transactions in parallel and handles rollback if any exception occurs.
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a parallel transaction executor with as many workers as there are available processors.ParallelTransactionExecutor
(String tenantId) ParallelTransactionExecutor
(String tenantId, int numWorkers) Instantiates a parallel transaction executor with the specified number of workers. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a command to the queue of commands to run in a transaction.void
Adds a command to the queue of commands to run in a transaction with the specified priority.void
run()
Runs the commands in parallel transactions and wait for completion.
-
Constructor Details
-
ParallelTransactionExecutor
public ParallelTransactionExecutor()Instantiates a parallel transaction executor with as many workers as there are available processors. -
ParallelTransactionExecutor
- Parameters:
tenantId
-
-
ParallelTransactionExecutor
Instantiates a parallel transaction executor with the specified number of workers.- Parameters:
tenantId
-numWorkers
-
-
-
Method Details
-
add
Adds a command to the queue of commands to run in a transaction.- Parameters:
command
-
-
add
Adds a command to the queue of commands to run in a transaction with the specified priority. Commands with the same priority will all be completed before moving on to commands with different priorities.- Parameters:
command
-priority
-
-
run
public void run()Runs the commands in parallel transactions and wait for completion. If an exception occurs in any command, all transactions are rolled back.
-