14.3.4 Handling Concurrent Asynchronus Operations
Using the PgxSession#runConcurrently
API provided by the graph
server (PGX), you can submit a list of suppliers of asynchronous APIs to run
concurrently in the PGX server.
For example:
import oracle.pgx.api.*;
Supplier<PgxFuture<?>> asyncRequest1 = () -> session.readGraphWithPropertiesAsync(...);
Supplier<PgxFuture<?>> asyncRequest2 = () -> session.getAvailableSnapshotsAsync(...);
List<Supplier<PgxFuture<?>>> supplierList = Arrays.asList(asyncRequest1, asyncRequest2);
//executing the async requests with the enabled optimization feature
List<?> results = session.runConcurrently(supplierList);
//the supplied requests are mapped to their results and orderly collected
PgxGraph graph = (PgxGraph) results.get(0);
Deque<GraphMetaData> metaData = (Deque<GraphMetaData>) results.get(1);
Parent topic: Handling Asynchronous Requests in Graph Server (PGX)