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 Details

    • ParallelTransactionExecutor

      public ParallelTransactionExecutor()
      Instantiates a parallel transaction executor with as many workers as there are available processors.
    • ParallelTransactionExecutor

      public ParallelTransactionExecutor(String tenantId)
      Parameters:
      tenantId -
    • ParallelTransactionExecutor

      public ParallelTransactionExecutor(String tenantId, int numWorkers)
      Instantiates a parallel transaction executor with the specified number of workers.
      Parameters:
      tenantId -
      numWorkers -
  • Method Details

    • 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.