PGX 21.1.1

Client Sessions

PGX is designed to support a Client-Server environment. It assumes there may be multiple concurrent clients, and that each client submits requests to the shared PGX instance independently. PGX utilizes the concept of sessions regardless of whether you are running PGX on your local machine or on a server.

Each session has its own workspace in PGX and is isolated from other sessions. The PGX Server Design page illustrates this aspect from a PGX server perspective.

PGX offers a mechanism to explicitly share objects (e.g., graphs or properties) among sessions; the Publishing a Graph page provides more information.

Creating Sessions

The following methods in the ServerInstance class are used to create sessions:

PgxFuture<PgxSession> createSessionAsync(String source)
PgxFuture<PgxSession> createSessionAsync(String source, long idleTimeout, long taskTimeout, TimeUnit unit)

PGX offers blocking convenience wrappers around the above methods:

PgxSession createSession(String source)
PgxSession createSession(String source, long idleTimeout, long taskTimeout, TimeUnit unit)

The above methods accept the following arguments:

  • source is any arbitrary string that describes the client. Currently, this string is only used for logging purposes.

  • The user can specify the idle timeout (idleTimeout) and task timeout (taskTimeout) when creating a new session. If these values are not specified, default values are used. See the PGX Configuration Guide for details.

No authentication

PGX does not provide an authentication mechanism on its own, but presumes that the application layer will do so. PGX uses HTTP Basic Auth in case PGX is deployed as a web application. You can find more information about this in our deployment tutorials for Tomcat and Weblogic.

Destroying Sessions

To destroy a session, simply call


or its blocking version:


Administrators can destroy sessions by ID using

PgxFuture<Void> promise = instance.killSessionAsync(sessionId);
instance.killSession(sessionId); // blocking version

Note: Calling administrative methods by default requires special authorization in client/server mode.

When a session is destroyed, PGX reclaims all of the resources associated with the session. Specifically, all transient data is destroyed immediately. However, PGX may choose to keep the loaded graph instance in memory for caching purposes, especially if a graph instance is shared by multiple clients. In summary, every graph remains in memory until no client is using it. Refer to the related documentation for details.

Also note that a session can be destroyed automatically via the session time-out mechanism. Refer to the configuration guide for details.