Class NestedTransaction

  • All Implemented Interfaces:
    AutoCloseable

    public final class NestedTransaction
    extends Object
    implements AutoCloseable
    A transaction which may contain a list of transactions, typically to represent a distributed transaction over multiple systems.
    Author:
    bratseth
    • Constructor Detail

      • NestedTransaction

        public NestedTransaction()
    • Method Detail

      • add

        @SafeVarargs
        public final NestedTransaction add​(Transaction transaction,
                                           Class<? extends Transaction>... before)
        Adds a transaction to this.
        Parameters:
        transaction - the transaction to add
        before - transaction classes which should commit after this, if present. It is beneficial to order transaction types from the least to most reliable. If conflicting ordering constraints are given this will not be detected at add time but the transaction will fail to commit
        Returns:
        this for convenience
      • transactions

        public List<Transaction> transactions()
        Returns the transactions nested in this, as they will be committed.
      • commit

        public void commit()
        Perform a 2 phase commit
      • onCommitted

        public void onCommitted​(Runnable runnable)
      • close

        public void close()
        Free up any temporary resources held by this
        Specified by:
        close in interface AutoCloseable