Using the Amazon SDK to run Gremlin queries
With the Amazon SDK, you can run Gremlin queries against your Neptune graph using
a programming language of your choice. The Neptune data API SDK (service name
neptunedata) provides the
ExecuteGremlinQuery
action for submitting Gremlin queries.
You must run these examples from an Amazon EC2 instance in the same virtual private cloud (VPC) as your Neptune DB cluster, or from a location that has network connectivity to your cluster endpoint.
Direct links to the API reference documentation for the neptunedata
service in each SDK language can be found below:
Gremlin Amazon SDK examples
The following examples show how to set up a neptunedata client,
run a Gremlin query, and print the results. Replace
YOUR_NEPTUNE_HOST and YOUR_NEPTUNE_PORT
with the endpoint and port of your Neptune DB cluster.
Client-side timeout and retry configuration
The SDK client timeout controls how long the client waits for a response. It does not control how long the query runs on the server. If the client times out before the server finishes, the query may continue running on Neptune while the client has no way to retrieve the results.
We recommend setting the client-side read timeout to 0 (no timeout)
or to a value that is at least a few seconds longer than the server-side
neptune_query_timeout
setting on your Neptune DB cluster. This lets Neptune control when queries
time out.
We also recommend setting the maximum retry attempts to 1 (no retries).
If the SDK retries a query that is still running on the server, it can result in
duplicate operations. This is especially important for mutation queries, where a
retry could cause unintended duplicate writes.