|
BLPAPI C++
3.24.12
|
#include <blpapi_providersession.h>
Public Types | |
| enum | ResolveMode { AUTO_REGISTER_SERVICES = 1, DONT_REGISTER_SERVICES = 0 } |
| typedef ::BloombergLP::blpapi::ProviderEventHandler | EventHandler |
Public Member Functions | |
| ProviderSession (const SessionOptions &options=SessionOptions(), EventHandler *eventHandler=0, EventDispatcher *eventDispatcher=0) | |
| virtual | ~ProviderSession () |
| virtual bool | start () |
| virtual bool | startAsync () |
| virtual void | stop () |
| virtual void | stopAsync () |
| virtual Event | nextEvent (int timeout=0) |
| virtual int | tryNextEvent (Event *event) |
| virtual bool | registerService (const char *serviceName, const Identity &providerIdentity=Identity(), const ServiceRegistrationOptions ®istrationOptions=ServiceRegistrationOptions()) |
| virtual void | activateSubServiceCodeRange (const char *serviceName, int begin, int end, int priority) |
| virtual void | deactivateSubServiceCodeRange (const char *serviceName, int begin, int end) |
| virtual CorrelationId | registerServiceAsync (const char *serviceName, const Identity &providerIdentity=Identity(), const CorrelationId &correlationId=CorrelationId(), const ServiceRegistrationOptions ®istrationOptions=ServiceRegistrationOptions()) |
| virtual bool | deregisterService (const char *serviceName) |
| virtual void | resolve (ResolutionList *resolutionList, ResolveMode resolveMode=DONT_REGISTER_SERVICES, const Identity &providerIdentity=Identity()) |
| virtual void | resolveAsync (const ResolutionList &resolutionList, ResolveMode resolveMode=DONT_REGISTER_SERVICES, const Identity &providerIdentity=Identity()) |
| virtual Topic | getTopic (const Message &message) |
| virtual Topic | createServiceStatusTopic (const Service &service) |
| virtual void | publish (const Event &event) |
| virtual void | sendResponse (const Event &event, bool isPartialResponse=false) |
| virtual void | createTopics (TopicList *topicList, ResolveMode resolveMode=DONT_REGISTER_SERVICES, const Identity &providerIdentity=Identity()) |
| virtual void | createTopicsAsync (const TopicList &topicList, ResolveMode resolveMode=DONT_REGISTER_SERVICES, const Identity &providerIdentity=Identity()) |
| virtual void | deleteTopic (const Topic &topic) |
| virtual void | deleteTopics (const std::vector< Topic > &topics) |
| virtual void | deleteTopics (const Topic *topics, size_t numTopics) |
| virtual void | terminateSubscriptionsOnTopic (const Topic &topic, const char *message=0) |
| virtual void | terminateSubscriptionsOnTopics (const std::vector< Topic > &topics, const char *message=0) |
| virtual void | terminateSubscriptionsOnTopics (const Topic *topics, size_t numTopics, const char *message=0) |
| virtual bool | flushPublishedEvents (int timeoutMsecs) |
| virtual bool | openService (const char *serviceIdentifier) |
| virtual CorrelationId | openServiceAsync (const char *serviceIdentifier, const CorrelationId &correlationId=CorrelationId()) |
| virtual CorrelationId | sendAuthorizationRequest (const Request &authorizationRequest, Identity *identity, const CorrelationId &correlationId=CorrelationId(), EventQueue *eventQueue=0) |
| virtual void | cancel (const CorrelationId &correlationId) |
| virtual void | cancel (const std::vector< CorrelationId > &correlationIds) |
| virtual void | cancel (const CorrelationId *correlationIds, size_t numCorrelationIds) |
| virtual CorrelationId | generateToken (const CorrelationId &correlationId=CorrelationId(), EventQueue *eventQueue=0) |
| virtual CorrelationId | generateToken (const char *userId, const char *ipAddress, const CorrelationId &correlationId=CorrelationId(), EventQueue *eventQueue=0) |
| virtual Service | getService (const char *serviceIdentifier) const |
| virtual Identity | createIdentity () |
| CorrelationId | generateAuthorizedIdentity (const AuthOptions &authOptions, const CorrelationId &cid=CorrelationId()) |
| Identity | getAuthorizedIdentity (const CorrelationId &correlationId=CorrelationId()) |
| std::string | sessionName () |
DEPRECATED | |
| virtual Topic | createTopic (const Message &message) |
DEPRECATED | |
| BLPAPI_DEPRECATE_ABSTRACT_SESSION_CREATE_USER_HANDLE UserHandle | createUserHandle () |
Friends | |
| void | blpapi_providerEventHandlerAdapter (blpapi_Event_t *event, blpapi_ProviderSession_t *session, void *userData) |
This class provides a session that can be used for providing services.
It inherits from AbstractSession. In addition to the AbstractSession functionality a ProviderSession provides the following functions to applications.
A provider can register to provide services using ProviderSession::registerService*. Before registering to provide a service the provider must have established its identity. Then the provider can create topics and publish events on topics. It can also get requests from the event queue and send responses back.
After users have registered a service they will start receiving subscription requests (TopicSubscribed message in TOPIC_STATUS) for topics which belong to the service. If the resolver has specified subServiceCode for topics in PermissionResponse, then only providers who have activated the subServiceCode will get the subscription request. Where multiple providers have registered the same service and sub-service code (if any), the provider that registered the highest priority for the sub-service code will receive subscription requests; if multiple providers have registered the same sub-service code with the same priority (or the resolver did not set a sub-service code for the subscription), the subscription request will be routed to one of the providers with the highest service priority.
| enum ResolveMode |
| Enumerator | |
|---|---|
| AUTO_REGISTER_SERVICES | Try to register services found in ResolutionList if necessary. |
| DONT_REGISTER_SERVICES | Fail to resolve a topic if the service has not already been registered. |
|
explicit |
Construct a Session using the optionally specified options, the optionally specified eventHandler, and the optionally specified eventDispatcher.
See the SessionOptions documentation for details on what can be specified in the options.
If eventHandler is not null then this Session will operate in asynchronous mode; otherwise, the Session will operate in synchronous mode.
If eventDispatcher is null and a not null eventHandler is provided, then the Session will create an EventDispatcher for this Session which will use a single thread for dispatching events. For more control over event dispatching a specific instance of EventDispatcher can be supplied. This can be used to share a single EventDispatcher amongst multiple Session objects.
If an eventDispatcher is supplied which uses more than one thread the Session will ensure that events which should be ordered are passed to callbacks in a correct order. For example, partial response to a request or updates to a single subscription.
The behavior is undefined if eventHandler is null and the eventDispatcher is not null.
Each EventDispatcher uses its own thread or pool of threads so if you want to ensure that a session which receives very large messages and takes a long time to process them does not delay a session that receives small messages and processes each one very quickly then give each one a separate EventDispatcher.
|
virtual |
Destructor.
|
virtual |
Register to receive, with the specified priority, subscriptions for the specified service that the resolver has mapped to a service code between the specified begin and the specified end values, inclusive. Numerically greater values of priority indicate higher priorities. The behavior of this function is undefined unless service has already been successfully registered, 0 <= begin <= end < (1 << 24), and priority is non-negative.
|
virtualinherited |
If the specified correlationId identifies a current request then cancel that request.
Once this call returns the specified correlationId will not be seen in any subsequent Message obtained from a MessageIterator by calling next(). However, any Message currently pointed to by a MessageIterator when cancel() is called is not affected even if it has the specified correlationId. Also any Message where a reference has been retained by the application may still contain the correlationId. For these reasons, although technically an application is free to re-use correlationId as soon as this method returns it is preferable not to aggressively re-use correlation IDs, particularly with an asynchronous Session.
|
virtualinherited |
For each value in the specified correlationIds which identifies a current request then cancel that request. Any values in the specified correlationIds which do not identify a current request are ignored.
Once this call returns the specified correlationIds will not be seen in any subsequent Message obtained from a MessageIterator by calling next(). However, any Message currently pointed to by a MessageIterator when cancel() is called is not affected even if it has one of the specified correlationIds. Also any Message where a reference has been retained by the application may still contain one of the correlationIds. For these reasons, although technically an application is free to re-use any of the correlationIds as soon as this method returns it is preferable not to aggressively re-use correlation IDs, particularly with an asynchronous Session.
|
virtualinherited |
For each value specified correlationIds and numCorrelationIds which identifies a current request then cancel that request. Any specified CorrelationId's which do not identify a current request are ignored.
Once this call returns the specified correlationIds will not be seen in any subsequent Message obtained from a MessageIterator by calling next(). However, any Message currently pointed to by a MessageIterator when cancel() is called is not affected even if it has one of the specified correlationIds. Also any Message where a reference has been retained by the application may still contain one of the correlationIds. For these reasons, although technically an application is free to re-use any of the correlationIds as soon as this method returns it is preferable not to aggressively re-use correlation IDs, particularly with an asynchronous Session.
|
virtualinherited |
Return a Identity which is valid but has not been authorized.
createTopics or createTopicsAsync instead.Create a topic from the specified message, which must be of type ResolutionSuccess.
|
virtual |
Creates the topics in the specified topicList and updates the topicList with the results of the creation process. If service needs to be registered, providerIdentity should be supplied. Once a call to this function returns, each entry in the topicList will have been updated with a new topic creation status.
Before createTopics() returns one or more RESOLUTION_STATUS events, zero or more SERVICE_STATUS events and one or more TOPIC_STATUS events are generated. If this is an asynchronous ProviderSession then these Events may be processed by the registered EventHandler before createTopics() has returned.
If providerIdentity is not provided, the session identity will be used if it has been authorized.
|
virtual |
Creates the topics in the specified topicList and updates the topicList with the results of the creation process. If service needs to be registered, providerIdentity should be supplied.
One or more RESOLUTION_STATUS events, zero or more SERVICE_STATUS events and one or more TOPIC_STATUS events are generated. If this is an asynchronous ProviderSession then these Events may be processed by the registered EventHandler before createTopics() has returned.
If providerIdentity is not provided, the session identity will be used if it has been authorized.
|
inherited |
Return a UserHandle which is valid but has not been authorized.
|
virtual |
De-register to receive subscriptions for the specified service that the resolver has mapped to a service code between the specified begin and the specified end values, inclusive. The behavior of this function is undefined unless service has already been successfully registered and 0 <= begin <= end < (1 << 24).
|
virtual |
Remove one reference from the specified topic. If the number of times this function, terminateSubscriptionsOnTopic, updateResolvedTopics or requireNewPermissionCheck are called is the same as the number of times topic was created by createTopics, then topic is deleted: a TopicDeleted message is delivered, preceded by TopicDeactivated message (See TopicLife Cycle" for additional details). The behavior of this function is undefined if topic has already been deleted. Further, the behavior is undefined if a provider attempts to publish a message on a deleted topic.
|
virtual |
Delete each topic in the specified topics. See deleteTopic(const Topic&) for additional details.
|
virtual |
Delete the first numTopics elements of the specified topics array. See deleteTopic(const Topic&) for additional details.
|
virtual |
Deregister the service, including all registered parts, identified by the specified serviceName. The identity in the service registration is reused to verify permissions for deregistration. If the service is not registered nor in pending registration, return false; return true otherwise. If the service is in pending registration, cancel the pending registration. If the service is registered, send a deregistration request; generate TOPIC_STATUS events containing a TopicUnsubscribed message for each subscribed topic, a TopicDeactivated message for each active topic and a TopicDeleted for each created topic; generate REQUEST_STATUS events containing a RequestFailure message for each pending incoming request; and generate a SERVICE_STATUS Event containing a ServiceDeregistered message. All published events on topics created on this service will be ignored after this method returns.
|
virtual |
Wait at most timeoutMsecs milliseconds for all the published events to be sent through the underlying channel. The method returns either as soon as all the published events have been sent out or when it has waited timeoutMs milliseconds. Return true if all the published events have been sent; false otherwise. The behavior is undefined unless the specified timeoutMsecs is a non-negative value. When timeoutMsecs is 0, the method checks if all the published events have been sent and returns without waiting.
|
inherited |
Generates an authorized Identity with the specified AuthOptions and optionally specified cid.
The optionally specified cid is used to track Event objects generated as a result of this call. Return the actual CorrelationId object that will identify the messages associated with the generated identity.
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 session then these Events may be processed by the registered EventHandler before generateAuthorizedIdentity() has returned.
|
virtualinherited |
Generate a token to be used for authorization. If an invalid authentication option is specified in session option or there is a failure to get authentication information based on authentication option, or if the authentication mode is MANUAL for a user or user and application authentication, then an InvalidArgumentException is thrown.
|
virtualinherited |
Generate a token to be used for authorization, using the specified userId and ipAddress. If the authentication mode is not MANUAL, if the userId or ipAddress are not valid or if there's a problem obtaining the authentication information based on the authentication options in SessionOptions, then an InvalidArgumentException is thrown.
|
inherited |
Returns the authorized Identity associated with correlationId
A NotFoundException is thrown if there is no Identity associated with correlationId, if the associated Identity is not authorized, or if correlationId is not given and the session Identity is not authorized.
|
virtualinherited |
Return a Service object representing the service identified by the specified serviceIdentifier
The serviceIdentifier must contain a fully qualified service name. That is, it must be of the form //<namespace>/<local-name>.
If the service identified by serviceIdentifier is not open or registered already then a NotFoundException is thrown.
Finds a previously created Topic object based on the specified message. The message must be one of the following types: TopicCreated, TopicActivated, TopicDeactivated, TopicSubscribed, TopicUnsubscribed, TopicRecap. If the message is not valid then invoking isValid() on the returned Topic will return false.
|
virtual |
Return the next available Event for this session. If there is no event available this will block for up to the specified timeout in milliseconds for an Event to arrive. A value of 0 for timeout (the default) indicates nextEvent() should not timeout and will not return until the next Event is available.
If nextEvent() returns due to a timeout it will return an event of type EventType::TIMEOUT.
If this is invoked on a Session which was created in asynchronous mode an InvalidStateException is thrown.
Implements AbstractSession.
|
virtualinherited |
Attempt to open the service identified by the specified serviceIdentifier and block until the service is either opened successfully or has failed to be opened. Return true if the service is opened successfully and false if the service cannot be successfully opened.
The serviceIdentifier must contain a fully qualified service name. That is, it must be of the form //<namespace>/<local-name>.
Before openService() returns a SERVICE_STATUS Event is generated. If this is an asynchronous Session then this Event may be processed by the registered EventHandler before openService() has returned.
|
virtualinherited |
Begin the process to open the service identified by the specified serviceIdentifier and return immediately. The optional specified correlationId is used to track Events generated as a result of this call. The actual correlationId which will identify Events generated as a result of this call is returned.
The serviceIdentifier must contain a fully qualified service name. That is, it must be of the form //<namespace>/<local-name>.
The application must monitor events for a SERVICE_STATUS Event which will be generated once the service has been successfully opened or the opening has failed.
|
virtual |
Publish messages contained in the specified event.
|
virtual |
Attempt to register the service identified by the specified serviceName and block until the service is either registered successfully or has failed to be registered. The optionally specified providerIdentity is used to verify permissions to provide the service being registered. The optionally specified registrationOptions is used to specify the group ID and service priority of the service being registered. Returns true if the service is registered successfully and false if the service cannot be registered successfully.
The serviceName must be a full qualified service name. That is it must be of the form //<namespace>/<local-name>.
This function does not return until a SERVICE_STATUS event has been generated. Note that if the session was created in asynchronous mode, the event may be processed before the function returns.
When providerIdentity is not provided, the session identity will be used if it has been authorized.
|
virtual |
Begin the process of registering the service identified by the specified serviceName and return immediately. The optionally specified providerIdentity is used to verify permissions to provide the service being registered. The optionally specified correlationId is used to identify Message objects generated as a result of this call. Return the actual CorrelationId object that will identify Message objects. The optionally specified registrationOptions is used to specify the group ID and service priority of the service being registered.
The serviceName must be a full qualified service name. That is it must be of the form //<namespace>/<local-name>.
The application must monitor events for a SERVICE_STATUS Event which will be generated once the service has been successfully registered or registration has failed.
When providerIdentity is not provided, the session identity will be used if it has been authorized.
|
virtual |
Resolves the topics in the specified resolutionList and updates the resolutionList with the results of the resolution process. If the specified resolveMode is ResolveMode::DONT_REGISTER_SERVICES (the default) then all the services referenced in the topics in the resolutionList must already have been registered using registerService(). If resolveMode is ResolveMode::AUTO_REGISTER_SERVICES then the specified providerIdentity should be supplied and ProviderSession will automatically attempt to register any services reference in the topics in the resolutionList that have not already been registered. Once resolve() returns each entry in the resolutionList will have been updated with a new status.
Before resolve() returns one or more RESOLUTION_STATUS events and, if resolveMode is ResolveMode::AUTO_REGISTER_SERVICES, zero or more SERVICE_STATUS events are generated. If this is an asynchronous ProviderSession then these Events may be processed by the processed by the EventHandler before resolve() has returned.
If providerIdentity is not provided, the session identity will be used if it has been authorized.
|
virtual |
Begin the resolution of the topics in the specified resolutionList. If the specified resolveMode is ResolveMode::DONT_REGISTER_SERVICES (the default) then all the services referenced in the topics in the resolutionList must already have been registered using registerService(). If resolveMode is ResolveMode::AUTO_REGISTER_SERVICES then the specified providerIdentity should be supplied and ProviderSession will automatically attempt to register any services reference in the topics in the resolutionList that have not already been registered.
One or more RESOLUTION_STATUS events will be delivered with the results of the resolution. These events may be generated before or after resolve() returns. If ResolveMode::AUTO_REGISTER_SERVICES is specified SERVICE_STATUS events may also be generated before or after resolve() returns.
If providerIdentity is not provided, the session identity will be used if it has been authorized.
|
virtualinherited |
Send the specified authorizationRequest and update the specified identity with the results. If the optionally specified correlationId is supplied, it is used; otherwise create a CorrelationId. The actual CorrelationId used is returned. If the optionally specified eventQueue is supplied all Events relating to this Request will arrive on that EventQueue.
A successful request will generate zero or more PARTIAL_RESPONSE Messages followed by exactly one RESPONSE Message. Once the final RESPONSE Message has been received the specified identity will have been updated to contain the users entitlement information and the CorrelationId associated with the request may be re-used. If the request fails at any stage a REQUEST_STATUS will be generated, the specified identity will not be modified and the CorrelationId may be re-used.
The identity supplied must have been returned from this Session's createIdentity() method. For example
|
virtual |
Send the response event for previously received request. If isPartialResponse is false, cleans up all the internal state associated with the request.
|
inherited |
Returns the session name.
|
virtual |
Attempt to start this Session and blocks until the Session has started or failed to start. If the Session is started successfully true is returned, otherwise false is returned. Before start() returns a SESSION_STATUS Event is generated. If this is an asynchronous Session then the SESSION_STATUS may be processed by the registered EventHandler before start() has returned. A Session may only be started once.
Implements AbstractSession.
|
virtual |
Attempt to begin the process to start this Session and return true if successful, otherwise return false. The application must monitor events for a SESSION_STATUS Event which will be generated once the Session has started or if it fails to start. If this is an asynchronous Session then the SESSION_STATUS Event may be processed by the registered EventHandler before startAsync() has returned. A Session may only be started once.
Implements AbstractSession.
|
virtual |
Stop operation of this session and block until all callbacks to EventHandler objects relating to this Session which are currently in progress have completed (including the callback to handle the SESSION_STATUS Event with SessionTerminated message this call generates). Once this returns no further callbacks to EventHandlers will occur. If stop() is called from within an EventHandler callback the behavior is undefined and may result in a deadlock. Once a Session has been stopped it can only be destroyed.
Implements AbstractSession.
|
virtual |
Begin the process to stop this Session and return immediately. The application must monitor events for a SESSION_STATUS Event with SessionTerminated message which will be generated once the Session has been stopped. After this SESSION_STATUS Event no further callbacks to EventHandlers will occur. This method can be called from within an EventHandler callback to stop Sessions using non-default (external) EventDispatcher. Once a Session has been stopped it can only be destroyed.
Implements AbstractSession.
|
virtual |
Delete the specified topic (See deleteTopic(const Topic&) for additional details). Furthermore, proactively terminate all current subscriptions on topic. The optionally specified message can be used to convey additional information to subscribers regarding the termination. This message is contained in the description of reason in a SubscriptionTerminated message.
|
virtual |
Terminate subscriptions on each topic in the specified topics. See terminateSubscriptionsOnTopic(const Topic&, const char* message) for additional details.
|
virtual |
Terminate subscriptions on the first numTopics topics in the specified topics. See terminateSubscriptionsOnTopic(const Topic&, const char* message) for additional details.
|
virtual |
If there are Events available for the session, load the next Event into event and return 0 indicating success. If there is no event available for the session, return a non-zero value with no effect on event. This method never blocks.
Implements AbstractSession.
|
friend |