|
dxFeed Graal CXX API v9.0.0
|
The event listeners of a subscription (DXFeedSubscription::addEventListener()) are called on a thread of the executor of the endpoint (DXEndpoint::Builder::withExecutor(); by default a pool of dxfeed.threadPoolSize threads, see DXEndpoint::DXFEED_THREAD_POOL_SIZE_PROPERTY).
The calls for one subscription are serial: the next batch of events is delivered only after all the listeners have returned from the previous one, so the order of the events is kept.
A listener that blocks or works long delays all the events of its subscription. The events wait in the buffers of the endpoint and of the server: the lasting events (for example Quote) are conflated, the newest values come late, and the other events may be dropped (DXFeedSubscription::getTotalDroppedEvents()). From the outside it looks like a delayed feed. A listener should only take the events and return: copy them into a queue of its own and process them on another thread, do not wait for locks, network or user input in the listener.
The library checks this and reports warnings through ErrorManager (ErrorInfo::Level::WARN, the component DXFeedSubscription, see Error handling):
Each check of a subscription reports at most one warning per the period DXFeedSubscription::WARNING_PERIOD_PROPERTY (1m by default; 0 reports every excess, inf only the first). The first excess is reported at once; the next warning tells how many excesses were since the previous one and the largest of them.
The values of the properties are time periods, as TimePeriod::valueOf() reads them: 0.1s, 5s, 1m, inf (never). A subscription reads the properties when it is created (System::setProperty() or the isolate arguments, see Isolate arguments): a change does not affect the subscriptions that exist. A value that is not a time period is reported as a warning once, and the default is used.
The opposite problem, a subscription that receives no events while its endpoint stays connected, is reported by the silence watchdog of the subscription, which is off by default: see DXFeedSubscription::setSilenceWatchdog(). Its function is called on a thread of the library, not of the executor of the endpoint.