Class InternalAsyncTransaction

java.lang.Object
org.neo4j.driver.internal.async.AsyncAbstractQueryRunner
org.neo4j.driver.internal.async.InternalAsyncTransaction
All Implemented Interfaces:
AsyncQueryRunner, AsyncTransaction

public class InternalAsyncTransaction extends AsyncAbstractQueryRunner implements AsyncTransaction
  • Constructor Details

  • Method Details

    • commitAsync

      public CompletionStage<Void> commitAsync()
      Description copied from interface: AsyncTransaction
      Commit this transaction in asynchronous fashion. This operation is typically executed as part of the CompletionStage chain that starts with a transaction. There is no need to close transaction after calling this method. Transaction object should not be used after calling this method.

      Returned stage can be completed by an IO thread which should never block. Otherwise IO operations on this and potentially other network connections might deadlock. Please do not chain blocking operations like CompletableFuture.get() on the returned stage. Consider using asynchronous calls throughout the chain or offloading blocking operation to a different Executor. This can be done using methods with "Async" suffix like CompletionStage.thenApplyAsync(Function) or CompletionStage.thenApplyAsync(Function, Executor).

      Specified by:
      commitAsync in interface AsyncTransaction
      Returns:
      new CompletionStage that gets completed with null when commit is successful. Stage can be completed exceptionally when commit fails.
    • rollbackAsync

      public CompletionStage<Void> rollbackAsync()
      Description copied from interface: AsyncTransaction
      Rollback this transaction in asynchronous fashion. This operation is typically executed as part of the CompletionStage chain that starts with a transaction. There is no need to close transaction after calling this method. Transaction object should not be used after calling this method.

      Returned stage can be completed by an IO thread which should never block. Otherwise IO operations on this and potentially other network connections might deadlock. Please do not chain blocking operations like CompletableFuture.get() on the returned stage. Consider using asynchronous calls throughout the chain or offloading blocking operation to a different Executor. This can be done using methods with "Async" suffix like CompletionStage.thenApplyAsync(Function) or CompletionStage.thenApplyAsync(Function, Executor).

      Specified by:
      rollbackAsync in interface AsyncTransaction
      Returns:
      new CompletionStage that gets completed with null when rollback is successful. Stage can be completed exceptionally when rollback fails.
    • closeAsync

      public CompletionStage<Void> closeAsync()
      Description copied from interface: AsyncTransaction
      Close the transaction. If the transaction has been committed or rolled back, the close is optional and no operation is performed. Otherwise, the transaction will be rolled back by default by this method.
      Specified by:
      closeAsync in interface AsyncTransaction
      Returns:
      new CompletionStage that gets completed with null when close is successful, otherwise it gets completed exceptionally.
    • isOpenAsync

      public CompletionStage<Boolean> isOpenAsync()
      Description copied from interface: AsyncTransaction
      Determine if transaction is open.
      Specified by:
      isOpenAsync in interface AsyncTransaction
      Returns:
      a CompletionStage completed with true if transaction is open and false otherwise.
    • runAsync

      public CompletionStage<ResultCursor> runAsync(Query query)
      Description copied from interface: AsyncQueryRunner
      Run a query asynchronously and return a CompletionStage with a result cursor.

      Example

       
       Query query = new Query( "MATCH (n) WHERE n.name = $myNameParam RETURN n.age" );
       CompletionStage<ResultCursor> cursorStage = session.runAsync(query);
       
       
      It is not allowed to chain blocking operations on the returned CompletionStage. See class javadoc for more information.
      Specified by:
      runAsync in interface AsyncQueryRunner
      Parameters:
      query - a Neo4j query
      Returns:
      new CompletionStage that gets completed with a result cursor when query execution is successful. Stage can be completed exceptionally when error happens, e.g. connection can't be acquired from the pool.
    • isOpen

      public boolean isOpen()