Package com.axelor.db
Class ParallelTransactionExecutor
- java.lang.Object
-
- com.axelor.db.ParallelTransactionExecutor
-
public class ParallelTransactionExecutor extends Object
Executes transactions in parallel and handles rollback if any exception occurs.
-
-
Constructor Summary
Constructors Constructor Description ParallelTransactionExecutor()
Instantiates a parallel transaction executor with as many workers as there are available processors.ParallelTransactionExecutor(String tenantId, String tenantHost)
ParallelTransactionExecutor(String tenantId, String tenantHost, int numWorkers)
Instantiates a parallel transaction executor with the specified number of workers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Runnable command)
Adds a command to the queue of commands to run in a transaction.void
add(Runnable command, int priority)
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 Detail
-
ParallelTransactionExecutor
public ParallelTransactionExecutor()
Instantiates a parallel transaction executor with as many workers as there are available processors.
-
ParallelTransactionExecutor
public ParallelTransactionExecutor(String tenantId, String tenantHost)
- Parameters:
tenantId
-tenantHost
-
-
-
Method Detail
-
add
public void add(Runnable command)
Adds a command to the queue of commands to run in a transaction.- Parameters:
command
-
-
add
public void add(Runnable command, int priority)
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.
-
-