You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/reference/gremlin-applications.asciidoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1017,7 +1017,7 @@ The following table describes the various YAML configuration options that Gremli
1017
1017
|authorization.authorizer |The fully qualified classname of an `Authorizer` implementation to use. |_none_
1018
1018
|authorization.config |A `Map` of configuration settings to be passed to the `Authorizer` when it is constructed. The settings available are dependent on the implementation. |_none_
1019
1019
|channelizer |The fully qualified classname of the `Channelizer` implementation to use. A `Channelizer` is a "channel initializer" which Gremlin Server uses to define the type of processing pipeline to use. By allowing different `Channelizer` implementations, Gremlin Server can support different communication protocols (e.g. WebSocket). |`WebSocketChannelizer`
1020
-
|closeSessionPostGraphOp |Controls whether a `Session` will be closed by the server after a successful TX_COMMIT or TX_ROLLBACK bytecode request. |_false_
1020
+
|closeSessionPostGraphOp |Controls whether a `Session` will be closed by the server after a successful TX_COMMIT or TX_ROLLBACK bytecode request. This setting should be enabled when clients use the `reuseConnectionsForSessions` option (see <<gremlin-java-connection-reuse>>), which allows transaction sessions to share pooled connections. Without this setting, sessions opened by `reuseConnectionsForSessions` will not be cleaned up after commit or rollback and will remain open on the server until the session timeout expires, leading to unnecessary resource consumption. Defaults to `false` for backward compatibility. |_false_
1021
1021
|enableAuditLog |The `AuthenticationHandler`, `AuthorizationHandler` and processors can issue audit logging messages with the authenticated user, remote socket address and requests with a gremlin query. For privacy reasons, the default value of this setting is false. The audit logging messages are logged at the INFO level via the `audit.org.apache.tinkerpop.gremlin.server` logger, which can be configured using the `logback.xml` file. |_false_
1022
1022
|graphManager |The fully qualified classname of the `GraphManager` implementation to use. A `GraphManager` is a class that adheres to the TinkerPop `GraphManager` interface, allowing custom implementations for storing and managing graph references, as well as defining custom methods to open and close graphs instantiations. To prevent Gremlin Server from starting when all graphs fails, the `CheckedGraphManager` can be used.|`DefaultGraphManager`
1023
1023
|graphs |A `Map` of `Graph` configuration files where the key of the `Map` becomes the name to which the `Graph` will be bound and the value is the file name of a `Graph` configuration file. |_none_
Copy file name to clipboardExpand all lines: docs/src/reference/gremlin-variants.asciidoc
+113-9Lines changed: 113 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -883,6 +883,112 @@ Please see the link:https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/
883
883
Transactions with Java are best described in <<transactions,The Traversal - Transactions>> section of this
884
884
documentation as Java covers both embedded and remote use cases.
885
885
886
+
[[gremlin-java-connection-reuse]]
887
+
=== Connection Reuse for Transactions
888
+
889
+
By default, each call to `g.tx()` opens a new dedicated WebSocket connection for the session that backs the
890
+
transaction. For workloads that issue many short-lived transactions, the overhead of repeatedly establishing and
891
+
tearing down WebSocket connections can become significant, particularly when the client and server are separated by
892
+
network latency.
893
+
894
+
The `reuseConnectionsForSessions` option on `Cluster.Builder` changes this behavior so that transaction sessions
895
+
borrow connections from the existing connection pool instead of creating dedicated ones. When a transaction commits or
896
+
rolls back, the borrowed connection is returned to the pool and becomes available for the next transaction.
897
+
898
+
==== Enabling Connection Reuse
899
+
900
+
This feature requires configuration on both the client and the server (if using Gremlin Server).
901
+
902
+
On the client, enable `reuseConnectionsForSessions` when building the `Cluster`:
903
+
904
+
[source,java]
905
+
----
906
+
Cluster cluster = Cluster.build("localhost")
907
+
.reuseConnectionsForSessions(true)
908
+
.create();
909
+
GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster));
910
+
----
911
+
912
+
The same setting can be specified in a YAML configuration file used with `Cluster.open()`:
913
+
914
+
[source,yaml]
915
+
----
916
+
reuseConnectionsForSessions: true
917
+
----
918
+
919
+
On servers based on the Gremlin Server, enable `closeSessionPostGraphOp` so that sessions are closed immediately after
920
+
a commit or rollback completes:
921
+
922
+
[source,yaml]
923
+
----
924
+
# gremlin-server.yaml
925
+
closeSessionPostGraphOp: true
926
+
----
927
+
928
+
IMPORTANT: Both settings must be configured together. If `reuseConnectionsForSessions` is enabled on the client but
929
+
`closeSessionPostGraphOp` is not enabled on the server, sessions will not be cleaned up after commit or rollback.
930
+
These leaked sessions will accumulate on the server until the configured session timeout is reached, consuming server
931
+
resources unnecessarily.
932
+
933
+
NOTE: Some Remote Gremlin Providers may handle session cleanup automatically and may not require explicit
934
+
`closeSessionPostGraphOp` configuration. Consult the provider's documentation to determine whether this behavior is
935
+
enabled by default, requires explicit configuration, or is unsupported.
936
+
937
+
==== Usage
938
+
939
+
The transaction API itself does not change when connection reuse is enabled. The standard pattern of `begin`, mutate,
940
+
and `commit` or `rollback` applies:
941
+
942
+
[source,java]
943
+
----
944
+
Cluster cluster = Cluster.build("localhost")
945
+
.reuseConnectionsForSessions(true)
946
+
.create();
947
+
GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster));
0 commit comments