The examples on the AWS documentation show how to connect to AWS Neptune using Gremlin as follows:
Cluster.Builder builder = Cluster.build();
builder.addContactPoint("your-neptune-endpoint");
builder.port(8182);
builder.enableSsl(true);
builder.keyCertChainFile("SFSRootCAG2.pem");
Cluster cluster = builder.create();
GraphTraversalSource g = EmptyGraph.instance().traversal().withRemote(DriverRemoteConnection.using(cluster));
However, my current code to connect to a generic Gremlin graph looks like:
Configuration conf = new PropertiesConfiguration(...);
... //Set configuration
Graph graph = GraphFactory.open(conf);
Does anyone know how to use this second approach with a GraphFactory to connect to Neptune? I haven't been able to find any examples anywhere.
Neptune does not provide a Graph
instance as Gremlin is executed remotely not locally. GraphFactory
is really only for situations where you have a Graph
instance you want to create. There used to be a RemoteGraph
that allowed for this (though still used in the TinkerPop test suite), but that approach has long since been abandoned and is no longer recommended.
The method for connecting to Remote Gremlin Providers like Neptune that you initially presented is the recommended way to establish the GraphTraversalSource
. It is worth noting however that as of 3.3.5 the preferred method gets rid of EmptyGraph
and allows you to instantiate the GraphTraversalSource
anonymously as follows:
import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
GraphTraversalSource g = traversal().withRemote('conf/remote-graph.properties');
There are other overloads for withRemote()
that should look familiar as well.