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
@@ -1016,7 +1016,7 @@ The following table describes the various YAML configuration options that Gremli
1016
1016
|authorization.authorizer |The fully qualified classname of an `Authorizer` implementation to use. |_none_
1017
1017
|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_
1018
1018
|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`
1019
-
|closeSessionPostGraphOp |Controls whether a `Session` will be closed by the server after a successful TX_COMMIT or TX_ROLLBACK bytecode request. |_false_
1019
+
|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_
1020
1020
|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_
1021
1021
|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`
1022
1022
|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
@@ -888,6 +888,112 @@ Please see the link:https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/
888
888
Transactions with Java are best described in <<transactions,The Traversal - Transactions>> section of this
889
889
documentation as Java covers both embedded and remote use cases.
890
890
891
+
[[gremlin-java-connection-reuse]]
892
+
=== Connection Reuse for Transactions
893
+
894
+
By default, each call to `g.tx()` opens a new dedicated WebSocket connection for the session that backs the
895
+
transaction. For workloads that issue many short-lived transactions, the overhead of repeatedly establishing and
896
+
tearing down WebSocket connections can become significant, particularly when the client and server are separated by
897
+
network latency.
898
+
899
+
The `reuseConnectionsForSessions` option on `Cluster.Builder` changes this behavior so that transaction sessions
900
+
borrow connections from the existing connection pool instead of creating dedicated ones. When a transaction commits or
901
+
rolls back, the borrowed connection is returned to the pool and becomes available for the next transaction.
902
+
903
+
==== Enabling Connection Reuse
904
+
905
+
This feature requires configuration on both the client and the server (if using Gremlin Server).
906
+
907
+
On the client, enable `reuseConnectionsForSessions` when building the `Cluster`:
908
+
909
+
[source,java]
910
+
----
911
+
Cluster cluster = Cluster.build("localhost")
912
+
.reuseConnectionsForSessions(true)
913
+
.create();
914
+
GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster));
915
+
----
916
+
917
+
The same setting can be specified in a YAML configuration file used with `Cluster.open()`:
918
+
919
+
[source,yaml]
920
+
----
921
+
reuseConnectionsForSessions: true
922
+
----
923
+
924
+
On servers based on the Gremlin Server, enable `closeSessionPostGraphOp` so that sessions are closed immediately after
925
+
a commit or rollback completes:
926
+
927
+
[source,yaml]
928
+
----
929
+
# gremlin-server.yaml
930
+
closeSessionPostGraphOp: true
931
+
----
932
+
933
+
IMPORTANT: Both settings must be configured together. If `reuseConnectionsForSessions` is enabled on the client but
934
+
`closeSessionPostGraphOp` is not enabled on the server, sessions will not be cleaned up after commit or rollback.
935
+
These leaked sessions will accumulate on the server until the configured session timeout is reached, consuming server
936
+
resources unnecessarily.
937
+
938
+
NOTE: Some Remote Gremlin Providers may handle session cleanup automatically and may not require explicit
939
+
`closeSessionPostGraphOp` configuration. Consult the provider's documentation to determine whether this behavior is
940
+
enabled by default, requires explicit configuration, or is unsupported.
941
+
942
+
==== Usage
943
+
944
+
The transaction API itself does not change when connection reuse is enabled. The standard pattern of `begin`, mutate,
945
+
and `commit` or `rollback` applies:
946
+
947
+
[source,java]
948
+
----
949
+
Cluster cluster = Cluster.build("localhost")
950
+
.reuseConnectionsForSessions(true)
951
+
.create();
952
+
GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster));
0 commit comments