Class UnmanagedTransaction


  • public class UnmanagedTransaction
    extends Object
    Maintains state for an active transaction over HTTP.

    Key design principle: Graph transactions are ThreadLocal-bound, so all operations for a transaction must execute on the same thread. This is achieved via a single-threaded executor. Callers submit FutureTask instances that contain the complete request lifecycle (graph operation, error handling, response writing), following the same pattern as the non-transactional HTTP path and the legacy SessionOpProcessor.

    • Constructor Detail

      • UnmanagedTransaction

        public UnmanagedTransaction​(String transactionId,
                                    TransactionManager transactionManager,
                                    Graph graph,
                                    ScheduledExecutorService scheduledExecutorService,
                                    long transactionTimeout,
                                    long perGraphClose)
        Creates a new UnmanagedTransaction for managing an HTTP transaction.
        Parameters:
        transactionId - The unique identifier for this transaction
        transactionManager - The manager that owns this transaction's lifecycle
        graph - The graph instance for this transaction
        scheduledExecutorService - Scheduler for timeout management
        transactionTimeout - Timeout in milliseconds before auto-rollback
    • Method Detail

      • getTransactionId

        public String getTransactionId()
        Returns the transaction ID.
      • touch

        public void touch()
        Resets the timeout for this transaction. Called on each request.
      • open

        public void open()
        Opens the underlying graph transaction and starts the inactivity timeout. Should be called on the transaction's single-threaded executor to preserve ThreadLocal affinity. On failure the exception is re-thrown and the caller is responsible for cleanup (e.g. via close(boolean)).
      • close

        public void close​(boolean force)
        Closes this transaction and releases its resources. When force is false, any open graph transaction is rolled back before shutdown. When force is true, the executor is shut down immediately without attempting a rollback.
        Parameters:
        force - if true, skip the rollback attempt and shut down immediately
      • submit

        public Future<?> submit​(FutureTask<Void> task)
        Submits a task to be executed within this transaction's thread context. The task should contain the complete request lifecycle: graph operation, error handling, and response writing.
        Parameters:
        task - The FutureTask to execute on the transaction thread
        Returns:
        Future that can be used for timeout cancellation
        Throws:
        IllegalStateException - if the transaction is closed