Skip to main content

KeySessionContext

Class

trading.keysquare.api.session.KeySessionContext

A KeySessionContext is required when creating a Session. This defines the configuration used for connectivity etc.

This class can be used directly or in conjunction with Config, which will bootstrap configuration from properties files.

KeySessionContext context = new KeySessionContext();
context.applicationName("sample-subscriber");
...

When used in conjunction with Config, the following values can be set in property files:

Application

PropertyDescription
APP_NAMEThis is the application name to use to connect to KeySquare. This app name must be pre-registered in KeyAccess and permissioned to access relevant data
APP_CPUSDefines the cpu(s) available to pin application threads
KS_APP_API_KEYThe api key to use when registering application on start up
KS_APP_APPLICATION_IDLE_STRATEGYThe idle strategy to use for the application thread when it has no messages to process, defaults to SleepingMillisIdleStrategy
KS_APP_CONCURRENCY_MODEDefines the concurrency mode of publication - when more than on thread will be publishing data the CONCURRENT mode should be used
KS_APP_SESSION_THREAD_NAMEDefines the thread name to use by the session
KS_APP_EDIT_API_SUPPORTEDCan be used to disable the Edit API - this can provide slightly improved performance in certain cases.
KS_APP_SHUTDOWN_HOOK_ENABLEDCan be used to disable the shutdown hook that gets automatically registered by the session
KS_APP_AUTO_RECONNECTCan be used to prevent automatic reconnection of the session following a disconnect
KS_APP_AUTO_RECONNECT_APPLY_SUBSCRIPTIONSCan be used to prevent the automatic application of subscriptions when an application is reconnected following a disconnect
KS_APP_AUTO_RECONNECT_REPUBLISHCan be used to prevent the automatic republication of data when an application is reconnected following a disconnect

Transport

PropertyDescription
KS_APP_TRANSPORT_MODEThe transport mode to use, e.g. IPC_UDP or TCP
KS_APP_TRANSPORT_EVENT_LIMITDefines the batch size of events being processed
KS_APP_TRANSPORT_IPC_UDP_DIRThe location of the aeron directory to use when in IPC_UDP mode
KS_APP_TRANSPORT_IPC_UDP_INTERFACEThe network interface to use when in IPC_UDP mode
KS_APP_TRANSPORT_TCP_BUFFER_SIZEThe TCP buffer size when operating in TCP mode

Monitoring

PropertyDescription
KS_APP_MONITORING_HEALTH_DIRECTORYDefines the health directory in which to write a health file once an application submits a LifeCycle Status of Online
KS_APP_MONITORING_BUFFER_SIZEThe monitoring buffer size
KS_APP_MONITORING_IDLE_STRATEGYThe monitoring thread idle strategy, defaults to SleepingMillisIdleStrategy
KS_APP_MONITORING_HEARTBEAT_INTERVAL_MILLISThe heartbeat interval in milliseconds
KS_APP_MONITORING_HEARTBEAT_TIMEOUT_MILLISThe heartbeat timeout in milliseconds

KeyAccess

PropertyDescription
KS_APP_KEY_ACCESS_URLThe URL location of the Key Access application used for application registration

Constructors

KeySessionContext()

Default constructor allowing configuration to be set via code.

KeySessionContext(trading.keysquare.api.config.Config config)

Constructor that can be used in conjunction with Config.