Package com.bloomberglp.blpapi
Class SessionOptions
java.lang.Object
com.bloomberglp.blpapi.SessionOptions
To use non-default options on a Session, create a SessionOptions instance and set the required
options and then supply it when creating a Session.
Currently the following options are supported
serverHost - The hostname or the ip address of the API server serverPort - The port number where the API server accepts connections maxSendCacheSize - Maximum number of bytes that will be cached by the Session before requests will fail maxEventQueueSize - The maximum number of events that can be buffered by the Session. The value of maxEventQueueSize must be greater than zero. maxPendingRequests - The maximum number of requests that can be pending allowMultipeCorrelatorsPerMsg - If a message is to be delivered for multiple correlators then deliver one message with all correlators folded into that one message slowConsumerWarningHiWaterMark - Set the fraction of 'maxEventQueueSize' at which "slow consumer" events will be generated. A warning event will be generated when the number of outstanding undelivered events passes above 'slowConsumerWarningHiWaterMark * maxEventQueueSize'. The following is applicable0.0 < slowConsumerWarningHiWaterMark <= 1.0
. Further, at the time that Session.start() is called, it must be the case thatslowConsumerWarningLoWaterMark * maxEventQueueSize < slowConsumerWarningHiWaterMark * maxEventQueueSize
. slowConsumerWarningLoWaterMark - Set the fraction of 'maxEventQueueSize' at which "slow consumer cleared" events will be generated. A warning cleared event will be generated when the number of outstanding undelivered events drops below 'slowConsumerWarningLoWaterMark * maxEventQueueSize'. The following is applicable0.0 <= slowConsumerWarningLoWaterMark < 1.0
. Further, at the time that Session.start() is called, it must be the case thatslowConsumerWarningLoWaterMark * maxEventQueueSize < slowConsumerWarningHiWaterMark * maxEventQueueSize
. defaultSubscriptionService - The name of the service to be used by default for subscriptions defaultTopicPrefix - The name of the topic prefix to be used for subscriptions if one is not provided clientMode - seeSessionOptions.ClientMode
serverAddresses - List of server addresses (hostname and port) where the API servers are running. autoRestartOnDisconnection - On disconnection from the back end should the session connect again to the next available API server numStartAttempts - The number of connection failures before session gives give up on connection connectTimeout - Timeout in milliseconds for session to establish a connection defaultKeepAliveInactivityTime - Amount of time in milliseconds without any read activity on the connection before the library will ping the peer (requires compatible server). defaultKeepAliveResponseTimeout - Timeout for the ping response in milliseconds. The peer will be declared "dead" if no ping response (or other data) is received within response timeout interval after the ping (requires compatible server). keepAliveEnabled - Whether all keep-alive mechanisms, both from the client to the server and from the server to the client, should be enabled. recordSubscriptionDataReceiveTimes - Should the receipt time (accessed viaMessage.timeReceivedMillis()
) be recorded for subscription data messages. TlsOptions - Use TLS when establishing connection to the API Server. If non-null, contains the client credentials and trust material that should be used to establish secure authenticated connections to the backend. A null TlsOptions (the default) indicates plaintext communication with the endpoints to which the session connects. bandwidthSaveModeDisabled - Flag indicating whether the client has requested to override bandwidth saving measures, such as conflation for snapshot subscriptions. By default it is 'false'. sessionIdentityOptions - Authorization options that enable automatic authorization of the session identity during startup.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Enumerations describing client mode of Sessionstatic class
-
Constructor Summary
ConstructorDescriptionConstruct a SessionOption with well defined defaults for various options Currently the following defaults are applied -
Method Summary
Modifier and TypeMethodDescriptionReturns authentication options as a string.boolean
Returns the value of the allow multiple correlators per message option in this instance.boolean
Returns if enabled to automatically restart connection on disconnection.boolean
Return the value of the flag indicating whether the client has disabled bandwidth saving measures.Returns the value of the client mode option in this instance.int
Returns the value of the connection timeout option in this instance in milliseconds.int
Returns the interval (in milliseconds) a connection has to remain inactive (receive no data) before a keep alive probe will be sent.int
Returns the time (in milliseconds) the library will wait for response to a keep alive probe before declaring it lost.String[]
Deprecated.Returns the default subscription service option.Returns the default topic prefix option.int
Returns the value of maximum outstanding undelivered events that the session is configured with.int
Returns the value of maximum outstanding requests that the session is configured with.int
Returns the value of the maximum pending request option in this instance.int
boolean
Returns if the receipt time (accessed viaMessage.timeReceivedMillis()
) should be recorded for subscription data messages.Returns the list of server addresses that this session is configured to connect to.Returns the value of the server host option in this instance.int
Returns the server port that this session connects to.int
Returns the value of the service check timeout option in this instance in milliseconds.int
Returns the value of the service download timeout option in this instance in milliseconds.float
Returns the fraction of maxEventQueueSize at which "slow consumer" event will be generated.float
Returns the fraction of maxEventQueueSize at which "slow consumer cleared" event will be generated.Returns the TLS options used to configure secure communication with endpoints.int
Return the maximum number of attempts to retry establishing each connection (so that at least one connection has been established) when starting the session.void
setAllowMultipleCorrelatorsPerMsg
(boolean allowMultipleCorrelatorsPerMsg) Sets whether the Session is allowed to associate more than one CorrelationId with a Message to the specified 'allowMultipleCorrelatorsPerMsg'.void
setAuthenticationOptions
(String authOptions) Sets the specified 'authOptions' as authentication option.void
setAutoRestartOnDisconnection
(boolean autoRestartOnDisconnection) Sets option of automatically restarting connection if disconnected.void
setBandwidthSaveModeDisabled
(boolean isDisabled) Set the flag to indicate whether the client has requested to disable bandwidth saving measures.void
setClientMode
(SessionOptions.ClientMode clientMode) Sets how to connect to the API.void
setConnectTimeout
(int timeoutMilliSeconds) Sets the connection timeout in milliseconds when connecting to the API.void
setDefaultKeepAliveInactivityTime
(int inactivityMsecs) Sets to the specified 'inactivityMsecs' the amount of time in milli-seconds that no traffic can be received on a connection before the ping-based keep-alive mechanism is triggered; if no traffic is received for this duration then a keep-alive ping is sent to the remote end to solicit a response.void
setDefaultKeepAliveResponseTimeout
(int timeoutMsecs) Sets the default keep live response timeout interval in milliseconds.void
setDefaultSubscriptionService
(String defaultSubscriptionService) Sets the default service for subscriptions which do not specify a subscription server to the specified 'serviceIdentifier'.void
setDefaultTopicPrefix
(String defaultTopicPrefix) Sets the default topic prefix to be used when a subscription does not specify a prefix to the specified 'prefix'.void
setKeepAliveEnabled
(boolean isEnabled) void
setMaxEventQueueSize
(int eventQueueSize) Sets the maximum number of outstanding un-delivered events per session to the specified 'eventQueueSize'.void
setMaxPendingRequests
(int pendingRequests) Sets the maximum number of requests which can be pending (submitted but have not received a final response (e.gEvent.EventType.RESPONSE
) to the specified 'maxPendingRequests'.void
setMaxSendCacheSize
(int writeCacheSize) void
setNumStartAttempts
(int numStartAttempts) Sets the maximum number of attempts to start a session by connecting a server.void
setRecordSubscriptionDataReceiveTimes
(boolean shouldRecord) Sets if the receipt time (accessed viaMessage.timeReceivedMillis()
) should be recorded for subscription data messages.void
setServerAddresses
(SessionOptions.ServerAddress[] serverAddresses) Sets the list of server address to the specified 'serverAddresses'.void
setServerHost
(String serverHost) Sets the API server host to connect to.void
setServerPort
(int serverPort) Set the port of the first element of the server list to the specified 'serverPort'.void
setServiceCheckTimeout
(int timeoutMsecs) Sets the timeout, in milliseconds, for identifying the version information for the service schema when opening a new service.void
setServiceDownloadTimeout
(int timeoutMsecs) Sets the timeout, in milliseconds, for downloading the service schema when opening a new service.setSessionIdentityOptions
(AuthOptions authOptions) Sets the specifiedauthOptions
as theAuthOptions
for the session identity with an automatically generatedCorrelationID
.void
setSessionIdentityOptions
(AuthOptions authOptions, CorrelationID correlationId) Sets the specifiedauthOptions
as theAuthOptions
for the session identity, enabling automatic authorization of the session identity during startup.void
setSlowConsumerWarningHiWaterMark
(float slowConsumerWarningHiWaterMark) Sets the point at which "slow consumer" events will be generated, using the specified 'highWaterMark' as a fraction of 'maxEventQueueSize'; the default value is 0.75.void
setSlowConsumerWarningLoWaterMark
(float slowConsumerWarningLoWaterMark) Sets the point at which "slow consumer cleared" events will be generated, using the specified 'loWaterMark' as a fraction of 'maxEventQueueSize'; the default value is 0.5.void
setTlsOptions
(TlsOptions tlsOptions) Sets theTlsOptions
used to configure secure communication with endpoints.toString()
-
Constructor Details
-
SessionOptions
public SessionOptions()Construct a SessionOption with well defined defaults for various options Currently the following defaults are appliedserverHost = "127.0.0.1" serverPort = 8194 maxSendCacheSize = 128MB maxEventQueueSize = 10000 maxPendingRequests = 1024 allowMultipeCorrelatorsPerMsg = false slowConsumerWarningHiWaterMark = 0.75 slowConsumerWarningLoWaterMark = 0.50 defaultSubscriptionService = "//blp/mktdata" defaultTopicPrefix = "/ticker/" clientMode =
SessionOptions.ClientMode.AUTO
keepAliveEnabled = true TlsOptions = null // do not use TLS
-
-
Method Details
-
getMaxEventQueueSize
public int getMaxEventQueueSize()Returns the value of maximum outstanding undelivered events that the session is configured with.- Returns:
- maximum outstanding event configuration
-
getMaxOutstandingRequests
public int getMaxOutstandingRequests()Returns the value of maximum outstanding requests that the session is configured with.- Returns:
- maximum outstanding request configuration
-
getMaxPendingRequests
public int getMaxPendingRequests()Returns the value of the maximum pending request option in this instance.- Returns:
- maximum pending request
-
getServerHost
Returns the value of the server host option in this instance. If multiple server address have been provided, return the host value specified in the first element of the server list.- Returns:
- server host
-
getServerPort
public int getServerPort()Returns the server port that this session connects to. If multiple addresses have been provided, return the port number specified in the first element of the server list.- Returns:
- server port
-
getServerAddresses
Returns the list of server addresses that this session is configured to connect to.- Returns:
- list of server addresses
-
getAutoRestartOnDisconnection
public boolean getAutoRestartOnDisconnection()Returns if enabled to automatically restart connection on disconnection.- Returns:
true
if configured to restart connection on disconnection andfalse
otherwise.
-
authenticationOptions
Returns authentication options as a string.- Returns:
- authentication options
-
numStartAttempts
public int numStartAttempts()Return the maximum number of attempts to retry establishing each connection (so that at least one connection has been established) when starting the session.- Returns:
- maximum start attempts
-
getMaxSendCacheSize
public int getMaxSendCacheSize() -
getAllowMultipleCorrelatorsPerMsg
public boolean getAllowMultipleCorrelatorsPerMsg()Returns the value of the allow multiple correlators per message option in this instance.- Returns:
- allow multiple correlators per message option
-
getSlowConsumerWarningHiWaterMark
public float getSlowConsumerWarningHiWaterMark()Returns the fraction of maxEventQueueSize at which "slow consumer" event will be generated.- Returns:
- slow consumer high watermark option
-
getSlowConsumerWarningLoWaterMark
public float getSlowConsumerWarningLoWaterMark()Returns the fraction of maxEventQueueSize at which "slow consumer cleared" event will be generated.- Returns:
- slow consumer low watermark option
-
getDefaultServices
Deprecated.as of 3.7.0, usegetDefaultSubscriptionService()
instead -
getDefaultSubscriptionService
Returns the default subscription service option. SeeSubscriptionList
for more information.- Returns:
- default subscription service option
-
getDefaultTopicPrefix
Returns the default topic prefix option. SeeSubscriptionList
for more information.- Returns:
-
getClientMode
Returns the value of the client mode option in this instance.- Returns:
- client mode option
-
getConnectTimeout
public int getConnectTimeout()Returns the value of the connection timeout option in this instance in milliseconds.- Returns:
- the connection timeout option
-
getServiceCheckTimeout
public int getServiceCheckTimeout()Returns the value of the service check timeout option in this instance in milliseconds.- Returns:
- the service check timeout option
-
getServiceDownloadTimeout
public int getServiceDownloadTimeout()Returns the value of the service download timeout option in this instance in milliseconds.- Returns:
- the service download timeout option
-
getDefaultKeepAliveInactivityTime
public int getDefaultKeepAliveInactivityTime()Returns the interval (in milliseconds) a connection has to remain inactive (receive no data) before a keep alive probe will be sent.- Returns:
- the default keep alive inactivity time interval option
-
getDefaultKeepAliveResponseTimeout
public int getDefaultKeepAliveResponseTimeout()Returns the time (in milliseconds) the library will wait for response to a keep alive probe before declaring it lost.- Returns:
- the default keep alive response timeout option
-
getRecordSubscriptionDataReceiveTimes
public boolean getRecordSubscriptionDataReceiveTimes()Returns if the receipt time (accessed viaMessage.timeReceivedMillis()
) should be recorded for subscription data messages. -
getTlsOptions
Returns the TLS options used to configure secure communication with endpoints.- Returns:
TlsOptions
object if configured to use TLS andnull
otherwise.
-
getBandwidthSaveModeDisabled
public boolean getBandwidthSaveModeDisabled()Return the value of the flag indicating whether the client has disabled bandwidth saving measures.- Returns:
- bandwidth saving measures disabled.
-
setMaxEventQueueSize
public void setMaxEventQueueSize(int eventQueueSize) Sets the maximum number of outstanding un-delivered events per session to the specified 'eventQueueSize'. All subsequent events delivered over the network will be dropped by the session if the number of outstanding un-delivered events is 'eventQueueSize', the specified threshold. The default value is 10000.- Parameters:
eventQueueSize
- the value to be set
-
setMaxPendingRequests
public void setMaxPendingRequests(int pendingRequests) Sets the maximum number of requests which can be pending (submitted but have not received a final response (e.gEvent.EventType.RESPONSE
) to the specified 'maxPendingRequests'. If the number of pending requests exceeds the specified threshold, subsequent call toSession.sendRequest(com.bloomberglp.blpapi.RequestTemplate, com.bloomberglp.blpapi.CorrelationID)
will generateRequestQueueOverflowException
. The default is 1024.- Parameters:
pendingRequests
- the value to be set
-
setServerHost
Sets the API server host to connect to. The specified 'serverHost' should be a hostname or an IPv4 address (that is, a.b.c.d). Only the first element in the server list is updated. The default is "127.0.0.1". Behavior is undefined if the specified 'serverHost' is an empty string.- Parameters:
serverHost
- the value to be set
-
setServerPort
public void setServerPort(int serverPort) Set the port of the first element of the server list to the specified 'serverPort'. The default is 8194.- Parameters:
serverPort
- the value to be set
-
setServerAddresses
Sets the list of server address to the specified 'serverAddresses'. Behavior is undefined if the specified 'serverAddresses' contains any serverAddress whose hostname is an empty string.- Parameters:
serverAddresses
- the value to be set
-
setAutoRestartOnDisconnection
public void setAutoRestartOnDisconnection(boolean autoRestartOnDisconnection) Sets option of automatically restarting connection if disconnected.- Parameters:
autoRestartOnDisconnection
- the value to be set
-
setAuthenticationOptions
Sets the specified 'authOptions' as authentication option.- Parameters:
authOptions
- the value to be set
-
setMaxSendCacheSize
public void setMaxSendCacheSize(int writeCacheSize) -
setAllowMultipleCorrelatorsPerMsg
public void setAllowMultipleCorrelatorsPerMsg(boolean allowMultipleCorrelatorsPerMsg) Sets whether the Session is allowed to associate more than one CorrelationId with a Message to the specified 'allowMultipleCorrelatorsPerMsg'. The default is 'false'. This means that if you have multiple subscriptions which overlap (that is a particular Message is relevant to all of them) you will be presented with the same message multiple times when you use the MessageIterator, each time with a different CorrelationId. If you specify 'true' for this then a Message may be presented with multiple CorrelationId's.- Parameters:
allowMultipleCorrelatorsPerMsg
- the value to be set
-
setSlowConsumerWarningHiWaterMark
public void setSlowConsumerWarningHiWaterMark(float slowConsumerWarningHiWaterMark) Sets the point at which "slow consumer" events will be generated, using the specified 'highWaterMark' as a fraction of 'maxEventQueueSize'; the default value is 0.75. A warning event will be generated when the number of outstanding un-delivered events passes above 'hiWaterMark * maxEventQueueSize'. The behavior of the function is undefined unless'0.0 < hiWaterMark <= 1.0'
. Further, at the time that 'Session.start()' is called, it must be the case that'slowConsumerWarningLoWaterMark() * maxEventQueueSize()' < 'slowConsumerWarningHiWaterMark() * maxEventQueueSize()'
.- Parameters:
slowConsumerWarningHiWaterMark
- the value to be set
-
setSlowConsumerWarningLoWaterMark
public void setSlowConsumerWarningLoWaterMark(float slowConsumerWarningLoWaterMark) Sets the point at which "slow consumer cleared" events will be generated, using the specified 'loWaterMark' as a fraction of 'maxEventQueueSize'; the default value is 0.5. A warning cleared event will be generated when the number of outstanding un-delivered events drops below 'loWaterMark * maxEventQueueSize'. The behavior of the function is undefined unless'0.0 <= loWaterMark < 1.0'
. Further, at the time that 'Session.start()' is called, it must be the case that'slowConsumerWarningLoWaterMark() * maxEventQueueSize()' < 'slowConsumerWarningHiWaterMark() * maxEventQueueSize()'
.- Parameters:
slowConsumerWarningLoWaterMark
- the value to be set
-
setDefaultSubscriptionService
Sets the default service for subscriptions which do not specify a subscription server to the specified 'serviceIdentifier'. The behavior is undefined unless 'serviceIdentifier' matches the regular expression^//[-_.a-zA-Z0-9]+/[-_.a-zA-Z0-9]+$
. The default is "//blp/mktdata". For more information on when this will be used see 'QUALIFYING SUBSCRIPTION STRINGS' section inSubscriptionList
.- Parameters:
defaultSubscriptionService
- the value to be set
-
setDefaultTopicPrefix
Sets the default topic prefix to be used when a subscription does not specify a prefix to the specified 'prefix'. The default is "/ticker/". For more information on when this will be used see 'QUALIFYING SUBSCRIPTION STRINGS' section inSubscriptionList
.- Parameters:
defaultTopicPrefix
- the value to be set
-
setClientMode
Sets how to connect to the API. The default isSessionOptions.ClientMode.AUTO
. InSessionOptions.ClientMode.AUTO
mode will try to connect to the desktop API but fall back to the server API if the desktop is not available.SessionOptions.ClientMode.DAPI
always connects to the desktop API and will fail if it is not available.SessionOptions.ClientMode.SAPI
always connects to the server API and will fail if it is not available.- Parameters:
clientMode
- the value to be set
-
setConnectTimeout
public void setConnectTimeout(int timeoutMilliSeconds) Sets the connection timeout in milliseconds when connecting to the API. The default is 5000 milliseconds. Behavior is not defined unless the specified 'timeoutMilliSeconds' is in range of [1 .. 120000] milliseconds.- Parameters:
timeoutMilliSeconds
- the value to be set
-
setNumStartAttempts
public void setNumStartAttempts(int numStartAttempts) Sets the maximum number of attempts to start a session by connecting a server.- Parameters:
numStartAttempts
- the value to be set
-
setDefaultKeepAliveInactivityTime
public void setDefaultKeepAliveInactivityTime(int inactivityMsecs) Sets to the specified 'inactivityMsecs' the amount of time in milli-seconds that no traffic can be received on a connection before the ping-based keep-alive mechanism is triggered; if no traffic is received for this duration then a keep-alive ping is sent to the remote end to solicit a response. If 'inactivityMsecs == 0', then no keep-alive pings will be sent. The behavior of this function is undefined unless 'inactivityMsecs' is a non-negative value. The default value is 20,000 milliseconds. Note that not all back-end connections provide ping-based keep-alives; this option is ignored by such connections.- Parameters:
inactivityMsecs
- the value to be set
-
setDefaultKeepAliveResponseTimeout
public void setDefaultKeepAliveResponseTimeout(int timeoutMsecs) Sets the default keep live response timeout interval in milliseconds. When a keep-alive ping is sent, wait for the specified 'timeoutMsecs' to receive traffic (of any kind) before terminating the connection due to inactivity. If 'timeoutMsecs == 0', then connections are never terminated due to the absence of traffic after a keep-alive ping. The behavior of this function is undefined unless 'timeoutMsecs' is a non-negative value. The default value is 5,000 milliseconds. Note that not all back-end connections provide support for ping-based keep-alives; this option is ignored by such connections.- Parameters:
timeoutMsecs
- the value to be set
-
setServiceCheckTimeout
public void setServiceCheckTimeout(int timeoutMsecs) Sets the timeout, in milliseconds, for identifying the version information for the service schema when opening a new service. The behavior of this function is undefined unless 'timeoutMsecs' is a positive value. The default value is 60,000 milliseconds.- Parameters:
timeoutMsecs
- the value to be set, in milliseconds
-
setServiceDownloadTimeout
public void setServiceDownloadTimeout(int timeoutMsecs) Sets the timeout, in milliseconds, for downloading the service schema when opening a new service. The behavior of this function is undefined unless 'timeoutMsecs' is a positive value. The default value is 120,000 milliseconds.- Parameters:
timeoutMsecs
- the value to be set, in milliseconds
-
setKeepAliveEnabled
public void setKeepAliveEnabled(boolean isEnabled) -
setRecordSubscriptionDataReceiveTimes
public void setRecordSubscriptionDataReceiveTimes(boolean shouldRecord) Sets if the receipt time (accessed viaMessage.timeReceivedMillis()
) should be recorded for subscription data messages. -
setTlsOptions
Sets theTlsOptions
used to configure secure communication with endpoints.- Parameters:
tlsOptions
- the value to be set. Set null value to disable TLS.
-
setBandwidthSaveModeDisabled
public void setBandwidthSaveModeDisabled(boolean isDisabled) Set the flag to indicate whether the client has requested to disable bandwidth saving measures.- Parameters:
isDisabled
- whether to disable bandwidth saving measures.
-
setSessionIdentityOptions
Sets the specifiedauthOptions
as theAuthOptions
for the session identity with an automatically generatedCorrelationID
.- Parameters:
authOptions
- TheAuthOptions
to use for the session identity.- Returns:
- The automatically generated
CorrelationID
that identifies the messages associated with the session identity. - See Also:
-
setSessionIdentityOptions
Sets the specifiedauthOptions
as theAuthOptions
for the session identity, enabling automatic authorization of the session identity during startup.The session identity lifetime is tied to the session's lifetime, so it is guaranteed that the session identity will remain authorized during the entire duration of the session. The identity will be authorized before the session starts. The session will terminate if the identity fails to authorize or is revoked.
The session identity is used to send requests and make subscriptions if no other identity is provided.
By default the session identity is not authorized.
The behavior is undefined if either
authOptions
orcorrelationId
is null.- Parameters:
authOptions
- TheAuthOptions
to use.correlationId
- TheCorrelationID
to identify the messages associated with the session identity.
-
toString
-
getDefaultSubscriptionService()
instead