Package com.axelor.db

Class ParallelTransactionExecutor


  • public class ParallelTransactionExecutor
    extends Object
    Executes transactions in parallel and handles rollback if any exception occurs.
    • 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 -
      • ParallelTransactionExecutor

        public ParallelTransactionExecutor​(String tenantId,
                                           String tenantHost,
                                           int numWorkers)
        Instantiates a parallel transaction executor with the specified number of workers.
        Parameters:
        tenantId -
        tenantHost -
        numWorkers -
    • 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.