Class SessionOptions

java.lang.Object
com.bloomberglp.blpapi.SessionOptions

public final class SessionOptions extends Object
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
                                   applicable 0.0 <
                                   slowConsumerWarningHiWaterMark <=
                                   1.0. Further, at the time that
                                   Session.start() is called, it must be the
                                   case that
                                   slowConsumerWarningLoWaterMark *
                                   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
                                   applicable 0.0 <=
                                   slowConsumerWarningLoWaterMark <
                                   1.0. Further, at the time that
                                   Session.start() is called, it must be the
                                   case that
                                   slowConsumerWarningLoWaterMark *
                                   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                      - see SessionOptions.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 via
                                   Message.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.
 applicationIdentityKey          - The application identity key (AIK) which
                                   uniquely identifies this application for
                                   this session.
 sessionName                     - The session name which can be used to
                                   identify the log lines pertaining to this
                                   session.
 
  • Constructor Details

    • SessionOptions

      public SessionOptions()
      Construct a SessionOption with well defined defaults for various options Currently the following defaults are applied
           serverHost                     = "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

      public String 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

      public SessionOptions.ServerAddress[] 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 and false otherwise.
    • authenticationOptions

      public String 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 public String[] getDefaultServices()
      Deprecated.
      as of 3.7.0, use getDefaultSubscriptionService() instead
    • getDefaultSubscriptionService

      public String getDefaultSubscriptionService()
      Returns the default subscription service option. See SubscriptionList for more information.
      Returns:
      default subscription service option
    • getDefaultTopicPrefix

      public String getDefaultTopicPrefix()
      Returns the default topic prefix option. See SubscriptionList for more information.
      Returns:
    • getClientMode

      public SessionOptions.ClientMode 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 via Message.timeReceivedMillis()) should be recorded for subscription data messages.
    • getTlsOptions

      public TlsOptions getTlsOptions()
      Returns the TLS options used to configure secure communication with endpoints.
      Returns:
      TlsOptions object if configured to use TLS and null 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.g Event.EventType.RESPONSE ) to the specified 'maxPendingRequests'. If the number of pending requests exceeds the specified threshold, subsequent call to Session.sendRequest(com.bloomberglp.blpapi.RequestTemplate, com.bloomberglp.blpapi.CorrelationID) will generate RequestQueueOverflowException. The default is 1024.
      Parameters:
      pendingRequests - the value to be set
    • setServerHost

      public void setServerHost(String serverHost)
      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

      public void setServerAddresses(SessionOptions.ServerAddress[] serverAddresses)
      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

      public void setAuthenticationOptions(String authOptions)
      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

      public void setDefaultSubscriptionService(String defaultSubscriptionService)
      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 in SubscriptionList.
      Parameters:
      defaultSubscriptionService - the value to be set
    • setDefaultTopicPrefix

      public void setDefaultTopicPrefix(String defaultTopicPrefix)
      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 in SubscriptionList.
      Parameters:
      defaultTopicPrefix - the value to be set
    • setClientMode

      public void setClientMode(SessionOptions.ClientMode clientMode)
      Sets how to connect to the API. The default is SessionOptions.ClientMode.AUTO. In SessionOptions.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 via Message.timeReceivedMillis()) should be recorded for subscription data messages.
    • setTlsOptions

      public void setTlsOptions(TlsOptions tlsOptions)
      Sets the TlsOptions 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

      public CorrelationID setSessionIdentityOptions(AuthOptions authOptions)
      Sets the specified authOptions as the AuthOptions for the session identity with an automatically generated CorrelationID.
      Parameters:
      authOptions - The AuthOptions to use for the session identity.
      Returns:
      The automatically generated CorrelationID that identifies the messages associated with the session identity.
      See Also:
    • setSessionIdentityOptions

      public void setSessionIdentityOptions(AuthOptions authOptions, CorrelationID correlationId)
      Sets the specified authOptions as the AuthOptions 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 or correlationId is null.

      Parameters:
      authOptions - The AuthOptions to use.
      correlationId - The CorrelationID to identify the messages associated with the session identity.
    • setApplicationIdentityKey

      public void setApplicationIdentityKey(String applicationIdentityKey)
      Sets the application identity key (AIK) which uniquely identifies this application for this session.
      Parameters:
      applicationIdentityKey - The application identity key to set.
      Throws:
      IllegalArgumentException - if applicationIdentityKey is null or empty, or consists exclusively of white-space characters.
    • getApplicationIdentityKey

      public String getApplicationIdentityKey()
      Returns:
      the application identity key (AIK) which uniquely identifies this application for this session.
    • setSessionName

      public void setSessionName(String sessionName)
      Sets the session name which can be used to identify the log lines pertaining to this session.
      Parameters:
      sessionName - the session name to be set
    • getSessionName

      public String getSessionName()
      Returns:
      the session name
    • toString

      public String toString()
      Overrides:
      toString in class Object