ISession Interface |
Sessions manage access to services either by requests and responses or subscriptions. A Session can dispatch events and replies in either a synchronous or asynchronous mode. The mode of a Session is determined when it is constructed and cannot be changed subsequently.
A session is asynchronous if an EventHandler is supplied when it is constructed. SetEventHandler(EventHandler, EventEventType) may be used to adjust the way events are handled subsequently and NextEvent may not be called. All incoming events are delivered to the event handler(s) supplied on construction or subsequently added with using SetEventHandler(EventHandler, EventEventType).
A session is synchronous if an EventHandler is not supplied when it is constructed. NextEvent must be called to read incoming events and SetEventHandler(EventHandler, EventEventType) may not be called.
When using an asynchronous Session the application must be aware that because the callbacks are generated from another thread they may be processed before the call which generates them has returned. For example, the SESSION_STATUSEvent generated by StartAsync may be processed before StartAsync returns (even though StartAsync itself will not block).
This becomes more significant when session-generated CorrelationID objects are in use. For example, if a call to Subscribe(IListSubscription, Identity, String) which returns a session-generated CorrelationID has not completed before the first events which contain that CorrelationID arrive the application may not be able to interpret those events correctly. For this reason, it is preferable to use a user generated CorrelationID when using an asynchronous Session. This issue does not arise when using a synchronous Session as long as the calls to Subscribe(IListSubscription, Identity, String) etc are made on the same thread as the calls to NextEvent.
Namespace: Bloomberglp.Blpapi
The ISession type exposes the following members.
Name | Description | |
---|---|---|
Cancel(CorrelationID) |
Cancels an outstanding request or a subscription.
(Inherited from IAbstractSession.) | |
Cancel(IListCorrelationID) |
This is the same as calling Cancel(CorrelationID, String)
with a null request label.
(Inherited from IAbstractSession.) | |
Cancel(CorrelationID, String) |
Cancels an outstanding request or a subscription.
(Inherited from IAbstractSession.) | |
Cancel(IListCorrelationID, String) |
Cancels outstanding requests or subscriptions.
(Inherited from IAbstractSession.)Cancels a previous request or subscription for asynchronous topic updates associated with each CorrelationID in correlators. Upon return, no further message will be generated for those requests or subscriptions. For asynchronous sessions, a handler may still be processing an existing message for the associated request or subscription after the call returns. While iterating over an event, if any message is encountered for a cancelled CorrelationID, it will be silently ignored, but if the message was iterated to just prior to the completion of the cancel request it will be delivered, it is up to the application developer to handle this condition. If any of the specified CorrelationIds do not refer to an "active" request or Subscription then, that particular CorrelationID will be ignored. Once this call returns, the specified CorrelationID can be reused for new requests to this session. Also note that application developers should generally be cautious not to reuse a CorrelationID until all existing references within their applications have been cleared. Depending on the use of the CorrelationID, this can possibly result in accessing application resources which are no longer available. | |
CreateIdentity |
Creates a new Identity which is valid but has not
been authorized.
(Inherited from IAbstractSession.)Create a handle to represent a user of services. For using services with the specific user's credentials the identity should be authorized with the corresponding authorization service. | |
createSnapshotRequestTemplate(String, CorrelationID) |
This is the same as calling
createSnapshotRequestTemplate(String, CorrelationID, Identity)
with null Identity.
| |
createSnapshotRequestTemplate(String, CorrelationID, Identity) |
Create a snapshot service request template for getting subscription
data.
When creating a snapshot requests a subscription is established, but messages are sent to the application only when requested. This reduces latency for receiving the latest data when compared to starting a new subscription each time. | |
GenerateAuthorizedIdentity |
Generates an authorized Identity with the specified
authOptions and cid.
(Inherited from IAbstractSession.)One or more AUTHORIZATION_STATUS events, zero or more TOKEN_STATUS events and zero or more SERVICE_STATUS events are generated. If this is an asynchronous AbstractSession then an Event may be processed by the registered EventHandler before GenerateAuthorizedIdentity(AuthOptions, CorrelationID) has returned. The behavior is undefined when authOptions is null. | |
GenerateToken |
This is the same as calling
GenerateToken(String, String, CorrelationID, IEventQueue)
with all null arguments.
(Inherited from IAbstractSession.) | |
GenerateToken(CorrelationID) |
This is the same as calling
GenerateToken(String, String, CorrelationID, IEventQueue)
with a null user ID and IP address and a null IEventQueue.
(Inherited from IAbstractSession.) | |
GenerateToken(CorrelationID, IEventQueue) |
This is the same as calling
GenerateToken(String, String, CorrelationID, IEventQueue)
with a null user ID and IP address.
(Inherited from IAbstractSession.) | |
GenerateToken(String, String, CorrelationID, IEventQueue) |
Generate a token to be used for authorization.
(Inherited from IAbstractSession.)Valid authentication options must have been specified in the SessionOptions. | |
GetAuthorizedIdentity |
Gets an authorized Identity.
A CorrelationID that maps to an authorized
Identity.
(Inherited from IAbstractSession.)If cid is omitted and the session identity is authorized, the function will return the session identity. An authorized identity must be mapped to cid. If cid is omitted the session identity must have been authorized. | |
GetService |
Gets the Service object.
(Inherited from IAbstractSession.) | |
GetSubscriptions |
Returns an enumerable collection of all subscriptions in this
session.
| |
GetSubscriptionStatus |
Returns the subscription status for a given CorrelationID.
| |
GetSubscriptionString |
Returns the subscription string for a given CorrelationID.
| |
NextEvent |
This is the same as NextEvent(Int64) with
0 milliseconds.
(Inherited from IAbstractSession.) | |
NextEvent(Int64) |
Returns the next event available for processing on this session.
(Inherited from IAbstractSession.)If no event is available immediately wait for timeoutMillis milliseconds for an event to arrive. If no event is received before the timeout expires return a TIMEOUT event. If the timeout specified is 0 then wait for an infinite amount of time for an event to be received. Note that this function cannot be called on a session that is operating in "asynchronous" mode. That is a session that was constructed with an EventHandler. An EventHandler must not have been provided at construction. | |
OpenService |
Opens the service.
(Inherited from IAbstractSession.) | |
OpenServiceAsync(String) |
Issues an asynchronous request to open a service.
(Inherited from IAbstractSession.) | |
OpenServiceAsync(String, CorrelationID) |
Initiates an asynchronous request to open a service.
(Inherited from IAbstractSession.)Once the request has completed, a SERVICE_STATUS event will be generated indicating the result of the request. The correlationId will be returned in generated message. It can also be used to cancel this request before it completes by calling Cancel(CorrelationID). | |
Resubscribe(IListSubscription) |
Modifies subscriptions to reflect the modified options specified
for them.
| |
Resubscribe(IListSubscription, Int32) |
This is the same as calling
Resubscribe(IListSubscription, Int32, String)
with null request label.
| |
Resubscribe(IListSubscription, String) |
Modifies subscriptions to reflect the modified options specified
for them.
| |
Resubscribe(IListSubscription, Int32, String) |
Modifies subscriptions to reflect the modified options specified
for them.
| |
SendAuthorizationRequest(Request, Identity, CorrelationID) |
This is the same as calling
SendAuthorizationRequest(Request, Identity, IEventQueue, CorrelationID, String)
with a null IEventQueue and null request label.
(Inherited from IAbstractSession.) | |
SendAuthorizationRequest(Request, Identity, CorrelationID, String) |
This is the same as calling
SendAuthorizationRequest(Request, Identity, IEventQueue, CorrelationID, String)
with a null IEventQueue.
(Inherited from IAbstractSession.) | |
SendAuthorizationRequest(Request, Identity, IEventQueue, CorrelationID) |
This is the same as calling
SendAuthorizationRequest(Request, Identity, IEventQueue, CorrelationID, String)
with a null request label.
(Inherited from IAbstractSession.) | |
SendAuthorizationRequest(Request, Identity, IEventQueue, CorrelationID, String) |
Authorizes an identity.
(Inherited from IAbstractSession.)This request can be used by applications to authorize users to receive data from services. If a user is successfully authorized all the entitlements for that user are cached locally. Once authorized the identity can be used to make subscriptions and requests as the user. If an IEventQueue is specified then all response events for this Authorization Request are published to this event queue. The user can block on this event queue for responses and can use this as a mechanism to convert this asynchronous request into a synchronous request. An Event will be published containing a message with the result of the authorization request. If the user was successfully authorized an "AuthorizationSuccess" message will be generated. If the user was not authorized an "AuthorizationFailure" message will be generated. | |
SendRequest(RequestTemplate) |
This is the same as calling SendRequest(RequestTemplate, CorrelationID)
with null CorrelationID.
| |
SendRequest(Request, CorrelationID) |
This is the same as calling
SendRequest(Request, Identity, IEventQueue, CorrelationID, String)
with null Identity, null IEventQueue
and null request label.
| |
SendRequest(RequestTemplate, CorrelationID) |
Send a request based on a RequestTemplate.
A successful request will generate zero or more PARTIAL_RESPONSE events followed by exactly one RESPONSE event. Once the final RESPONSE event has been received the CorrelationID associated with this request may be re-used. If the request fails at any stage a REQUEST_STATUS will be generated after which the CorrelationID associated with the request may be re-used. | |
SendRequest(Request, CorrelationID, String) |
This is the same as calling
SendRequest(Request, Identity, IEventQueue, CorrelationID, String)
with null Identity and null IEventQueue.
| |
SendRequest(Request, Identity, CorrelationID) |
This is the same as calling
SendRequest(Request, Identity, IEventQueue, CorrelationID, String)
with null IEventQueue and null request label.
| |
SendRequest(Request, IEventQueue, CorrelationID) |
This is the same as calling
SendRequest(Request, Identity, IEventQueue, CorrelationID, String)
with null Identity and null request label.
| |
SendRequest(Request, Identity, CorrelationID, String) |
This is the same as calling
SendRequest(Request, Identity, IEventQueue, CorrelationID, String)
with null IEventQueue.
| |
SendRequest(Request, Identity, IEventQueue, CorrelationID) |
This is the same as calling
SendRequest(Request, Identity, IEventQueue, CorrelationID, String)
with null request label.
| |
SendRequest(Request, IEventQueue, CorrelationID, String) |
This is the same as calling
SendRequest(Request, Identity, IEventQueue, CorrelationID, String)
with null Identity.
| |
SendRequest(Request, Identity, IEventQueue, CorrelationID, String) |
Sends a request to a service.
A successful request will generate zero or more PARTIAL_RESPONSE events followed by exactly one RESPONSE event. Once the final RESPONSE event has been received the CorrelationID associated with this request may be re-used. If the request fails at any stage a REQUEST_STATUS event will be generated after which the CorrelationID associated with the request may be re-used. The number of enqueued requests must not exceed the amount specified in MaxPendingRequests when this session was created. | |
SetEventHandler |
Set event specific event handlers.
| |
Start |
Issues a blocking call to start the session.
(Inherited from IAbstractSession.)A SESSION_STATUS event may be published containing a message with the result of the request. If the session was started successfully a "SessionStarted" message will be generated. If the start failed a "SessionStartupFailure" message may be generated. Note: If this is an asynchronous session then the SESSION_STATUS event may be processed by the registered EventHandler before this method has returned. If this session is using an external EventDispatcher it should be already started. A session must only be started once. | |
StartAsync |
Initiates a non blocking call to start the session.
(Inherited from IAbstractSession.)On completion of this request a SESSION_STATUS event is published containing a message with the result of the request. If the session was started successfully a "SessionStarted" message will be generated. If the start failed a "SessionStartupFailure" message will be generated. Note: If this is an asynchronous session then the SESSION_STATUS may be processed by the registered EventHandler before this method has returned. If this session is using an external EventDispatcher it should be already started. A session must only be started once. | |
Stop |
This is the same as calling
Stop(AbstractSessionStopOption)
with SYNC.
(Inherited from IAbstractSession.) | |
Stop(AbstractSessionStopOption) |
Stops this session.
(Inherited from IAbstractSession.) | |
Subscribe(IListSubscription) |
This is the same as calling
Subscribe(IListSubscription, Identity, String)
with null Identity and null request label.
| |
Subscribe(IListSubscription, Identity) |
This is the same calling
Subscribe(IListSubscription, Identity, String)
with null request label.
| |
Subscribe(IListSubscription, String) |
This is the same as calling
Subscribe(IListSubscription, Identity, String)
with null Identity.
| |
Subscribe(IListSubscription, Identity, String) |
Initiates a request to receive asynchronous updates to the
specified topics.
Upon completion of this request a SUBSCRIPTION_STATUS event will be published for each topic in the subscription list containing a message with the result for one topic. A "SubscriptionStarted" message will be generated if the subscription was successfully initiated. If the subscription fails for any topic a "SubscriptionFailure" message containing the failure reason will be generated. Any subscriptions in subscriptionList which were not given a application generated CorrelationID will have a session generated CorrelationID set. Multiple subscriptions to the same subscription string are valid and each will have their own, unique CorrelationID. In the case of an exception none of the subscriptions will be processed. | |
TryNextEvent |
Retrieves the next event available for processing on this session.
(Inherited from IAbstractSession.)This method never blocks. An EventHandler must not have been provided at construction. | |
Unsubscribe(IListSubscription) |
This is the same as calling
Unsubscribe(IListSubscription, String)
with null request label.
| |
Unsubscribe(IListSubscription, String) |
Cancel a list of subscriptions.
If the CorrelationID of any entry in the list does not identify a current subscription then that entry is ignored. See Cancel(CorrelationID) for more information on the handling of cancel requests. |