I'm trying to use Gremlin sessions with Amazon Neptune and using GroovyTranslator
to submit String
queries, as shown in below snippet
Client.SessionedClient sclient = cluster.connect(sessionId, false);
GraphTraversalSource g = EmptyGraph.instance().traversal().withRemote(DriverRemoteConnection.using(sclient))
Traversal t1 = g.addV("Person").property(T.id, 1).property("Name", "Justin"); ------ 1
sclient.submit(GroovyTranslator.of("g").translate(t1.asAdmin().getBytecode()))
Traversal t2 = g.addV("Person").property(T.id, 2).property("Name", "Langer"); ------ 2
sclient.submit(GroovyTranslator.of("g").translate(t2.asAdmin().getBytecode()))
// throw SomeException("some exeception....") ------------------------------ 3
Traversal t4 = g.addE("Edge Label").from(g.V(1)).to(g.V(2)); ------------------- 4
sclient.submit(GroovyTranslator.of("g").translate(t2.asAdmin().getBytecode()))
// all operations done now close sessioned client
sclient.close(); -------------------------------------------------------------
In above if an exception thrown from 3
then it won't close SessionedClient
till it timeouts.
We can move sclient.close()
to finally
block using try-catch
, this will execute 1
and 2
which actually should not be created as its executing as single transaction.
So I wanted to know if I can clear submitted queries (here in this case 1
and 2
) and close the SessionedClient
without executing already submitted queries.