1 \addtogroup handler-events
3 \brief Uncovers the Handler processing machinery regarding
4 events raised by the Handler while processing market data.
6 \details Market data processing assumes performance or different procedures
7 like a large-scale recovery to catch-up up-to-date market state on late join
8 or requesting lost incremental data. While developing a trading solution, it's
9 important to know in which state market data processing currently resides.
11 To meet needs, the SDK exposes the OnixS::CME::MDH::HandlerListener
12 listener. The Handler invokes members of the given listener once instances
13 are bound using the OnixS::CME::MDH::Handler::registerListener member.
15 The following table summaries the Handler events.
24 OnixS::CME::MDH::HandlerListener::onStarted
27 Invoked by the Handler when it starts market data processing
28 due to calling the OnixS::CME::MDH::Handler::start member.
33 OnixS::CME::MDH::HandlerListener::onStopped
36 Invoked by the Handler when it ends market data processing
37 due to calling the OnixS::CME::MDH::Handler::start member.
42 OnixS::CME::MDH::HandlerListener::onInstrumentRecovery
45 Invoked when the Handler spawns an instrument recovery.
50 OnixS::CME::MDH::HandlerListener::onEndOfInstrumentRecovery
53 Invoked when the Handler accomplishes an instrument recovery.
54 The Handler supplies the status of recovery (successful, incomplete,
55 failed) as an additional parameter.
60 OnixS::CME::MDH::HandlerListener::onMarketRecovery
63 Invoked when the Handler spawns a market recovery.
68 OnixS::CME::MDH::HandlerListener::onEndOfMarketRecovery
71 Invoked when the Handler accomplishes a market recovery.
72 The Handler supplies the status of recovery (successful,
73 incomplete, failed) as an additional parameter.
78 OnixS::CME::MDH::HandlerListener::onTcpRecovery
81 Invoked when the Handler recovers lost data via a TCP recovery feed.
86 OnixS::CME::MDH::HandlerListener::onEndOfTcpRecovery
89 Invoked when the Handler accomplishes recovering lost data via a TCP feed.
90 The Handler supplies the status of recovery (successful, incomplete, failed)
91 as an additional parameter.
96 OnixS::CME::MDH::HandlerListener::onRealtimeProcessing
99 Invoked by the Handler when real-time processing of incremental
100 data is either started or resumed after recovery of any kind (TCP,
101 snapshots). After invocation of the given callback, it is guaranteed
102 that incremental data is processed as soon as it arrives and without
103 any delays in processing.
108 OnixS::CME::MDH::HandlerListener::onEndOfRealtimeProcessing
111 Invoked when the Handler suspends real-time processing of
112 incremental data due to a processing issue or data loss.
117 \section handler-event-invocation-seq Event Invocation Sequence
119 The configuration and settings for data processing session define
120 the behavior of the Handler. Therefore, each market data processing
121 pattern defines a primary sequence of events the Handler raises.
122 Also, a sequence of events depends on the conditions the Handler occurs.
123 For example, if data is lost, the Handler may perform recovery
124 procedures according to its configuration. An issue may take place during
125 recovery or data processing. Therefore, *a chain of events is not
126 strictly defined for live market data processing, although there's
127 explicit predictability in events for each case and conditions the
130 The following sections guide through the Handler behavior for major cases.
132 \note For each case which may take place while processing market data,
133 the Handler has an established procedure which defines exact behavior for
134 the case. Therefore, it's not necessary to perform any additional steps
135 to instruct the Handler what to do in the case. The Handler manages
136 itself and notifies the users on stages of its behavior.
138 \section instrument-recovery-events Instrument Definition Recovery and Events
140 When the Handler starts performing instrument definition recovery,
141 it invokes the OnixS::CME::MDH::HandlerListener::onInstrumentRecovery
142 callback. The event is raised before any instrument definition is
143 processed. Once instrument recovery is started, the Handler listens
144 to data on instrument feed and processes received packets. The end
145 of recovery is detected by the Handler based on data processed. The
146 Handler calls the OnixS::CME::MDH::HandlerListener::onEndOfInstrumentRecovery
147 upon the end of successful processing of an instrument definition recovery loop.
149 The Handler may invoke the
150 OnixS::CME::MDH::HandlerListener::onInstrumentRecovery
151 and the OnixS::CME::MDH::HandlerListener::onEndOfInstrumentRecovery
152 members multiple times before it switches performing other steps
153 like market recovery or resumes real-time processing. The given behavior
154 may happen due to issues experienced by the Handler while processing
155 data from an instrument feed. If error occurs, the Handler will
156 call the OnixS::CME::MDH::HandlerListener::onEndOfInstrumentRecovery
157 with the OnixS::CME::MDH::RecoveryCompletionArgs::status equal to
158 OnixS::CME::MDH::RecoveryCompletionStatus::Failed.
159 The OnixS::CME::MDH::RecoveryCompletionArgs::details member includes
160 a detailed description of the issue caused recovery failure.
162 As noted in previous sections, users do not need to perform any additional
163 steps in such case. The Handler automatically restarts an instrument
164 recovery procedure. The instrument recovery is restarted as many times
165 as necessary to get successful processing of single recovery loop.
167 \subsection insrument-cache-events Recoverying Insrument Definition from Cache
169 The Handler may recover instrument definitions from a previously
170 saved cache. Using an instrument definition cache usually helps
171 to quickly pass an instrument definition recovery stage and move
172 to further processing. From events perspective, the Handler raises
173 the same pair of events identifying the beginning and the end of
174 the instrument definition recovery.
176 If an instrument definition cache is corrupted or can't be successfully
177 processed for any other reason, the Handler will end recovery from cache
178 by invoking the OnixS::CME::MDH::HandlerListener::onEndOfInstrumentRecovery
179 with the OnixS::CME::MDH::RecoveryCompletionArgs::status equal to the
180 OnixS::CME::MDH::RecoveryCompletionStatus::Failed.
182 If cache is not yet available, the Handler will end recovery from the cache
183 by invoking the OnixS::CME::MDH::HandlerListener::onEndOfInstrumentRecovery
184 with the OnixS::CME::MDH::RecoveryCompletionArgs::status equal to the
185 OnixS::CME::MDH::RecoveryCompletionStatus::Incomplete.
187 In both cases (if the cache is either corrupted or not yet available) the
188 Handler restarts an instrument definition recovery from the live network
191 The following diagram represents a visual
192 overview of the instrument definition recovery:
194 
196 \section market-recovery-events Market State Recovery and Events
198 Market recovery procedure may be spawned by the Handler to catch-up up-to-date
199 market state while joining market or due to other reasons like processing failure.
201 When the Handler starts performing market recovery, it invokes
202 the OnixS::CME::MDH::HandlerListener::onMarketRecovery callback.
203 The event is raised before any snapshot is processed.
204 Once a market state recovery is started, the Handler listens to
205 data on snapshot feeds and processes received data. The end of
206 recovery is detected by the Handler based on data processed. The
207 Handler calls the OnixS::CME::MDH::HandlerListener::onEndOfMarketRecovery
208 upon the end of successful processing of the snapshot recovery loop.
210 The Handler may invoke the OnixS::CME::MDH::HandlerListener::onMarketRecovery
211 and the OnixS::CME::MDH::HandlerListener::onEndOfMarketRecovery multiple
212 times before it resumes real-time processing of incremental data. The given
213 behavior may take place due to issues experienced by the Handler while processing
214 data like gaps in cached incremental data. If an error occurs, the Handler
215 calls the OnixS::CME::MDH::HandlerListener::onEndOfMarketRecovery with
216 the OnixS::CME::MDH::RecoveryCompletionArgs::status equal to
217 OnixS::CME::MDH::RecoveryCompletionStatus::Failed. The
218 OnixS::CME::MDH::RecoveryCompletionArgs::details member includes
219 a detailed description of the issue caused recovery failure.
221 Similar to the instrument definition recovery, users do not need to
222 perform any additional steps in such case. The Handler automatically
223 restarts a market recovery procedure. The market recovery is restarted
224 as many times as necessary to get successful processing of snapshot
227 The Handler may switch performing an instrument recovery before repeating
228 an attempt to recover a market state from snapshots in case of market recovery
229 failure. The given behavior happens if a processing session is configured to
230 recover both instruments and the market state on data gap or processing failure
231 (see the OnixS::CME::MDH::GapAndErrorHandlingOptions::RecoverInstrumentsAndMarketState
232 for more information).
234 A market recovery can accomplish with the
235 OnixS::CME::MDH::RecoveryCompletionStatus::Incomplete status.
236 When the Handler ends processing of recovery data from snapshots,
237 it applies incremental data queued during recovery. While processing
238 queued incremental data, The Handler verifies market recovery integrity.
239 It may happen that MDP did not send snapshot for an instrument which
240 incremental book updates were queued during the recovery. In such case,
241 the Handler restarts the market recovery to avoid book maintenance errors.
243 \note The described MDP behavior is not considered as an error.
244 Therefore, if a processing session is configured to recover instruments
245 in case of data loss and processing errors, the Handler does not
246 recover instruments if the market recovery ends with
247 OnixS::CME::MDH::RecoveryCompletionStatus::Incomplete status.
249 \subsection market-recovery-parts Market By Order and Market By Price Recovery
251 A market recovery may assume processing of recovery data from multiple
252 sources. With the invention of Market By Order functionality, CME MDP now
253 offers two independent sources of recovery data for market by order and
254 market by price. The Handler processes recovery loops from either one or
255 all sources depending on the settings of a processing session (see the
256 OnixS::CME::MDH::SesionSettings::marketRecovery parameter for more
257 information). From the event perspective, there's no difference whether
258 the Handler performs recovery of the market by order or price or both. *All
259 recovery-related steps, including processing of queued incremental data
260 after processing snapshots, is done between invocations of the
261 OnixS::CME::MDH::HandlerListener::onMarketRecovery and the
262 OnixS::CME::MDH::HandlerListener::onEndOfMarketRecovery
265 
267 \section realtime-processing-events Real-time Processing of Incremental Data
269 When the Handler either starts or resumes processing of incremental
270 data after recovery, it notifies about the given event via the
271 OnixS::CME::MDH::HandlerListener::onRealtimeProcessing callback.
272 Real-time processing of incremental data means that data is processed
273 as soon as it is received without any delays (except the case when the
274 Handler keeps out-of-order data waiting for a short period of time
275 for missing data to arrive).
277 By invoking the OnixS::CME::MDH::HandlerListener::onRealtimeProcessing
278 the Handler informs on the fact incremental data is not processed under
279 other conditions like the market or TCP recovery.
281 If the Handler faces an issue like a gap in incremental data
282 or book maintenance error, it suspends real-time processing
283 of the incremental data and signals about this via the
284 OnixS::CME::MDH::HandlerListener::onEndOfRealtimeProcessing.
285 Once the callback is invoked, the Handler performs an issue
286 handling according to its settings. For example, if the Handler
287 detected a gap in incremental data and the TCP recovery service
288 is bound to the Handler, it tries to recover missing packets using
289 the TCP recovery facility. At the given stage the Handler raises
290 events which are related to TCP recovery. Similar, if the Handler
291 spawns a large-scale market recovery, then the events related with
292 the market and optionally instrument recovery are raised. When
293 an issue handling is accomplished, the Handler resumes real-time
294 processing of incremental data and notify a user code about this using
295 the OnixS::CME::MDH::HandlerListener::onRealtimeProcessing member.
297 The diagram below visualizes aspects of the real-time processing of incremental data:
299 
301 \section tcp-recovery-events Recovering Missing Data from TCP Recovery Feed
303 CME MDP offers the TCP Recovery Feed to let applications
304 recover missing data without spawning a large-scale recovery
305 from snapshots. The Handler supports given functionality by
306 using a bound instance of the OnixS::CME::MDH::TcpRecoveryService
307 class. When a gap in incremental data is detected, the Handler
308 suspends real-time processing of incremental data and tries to
309 recover missing packets via the TCP recovery service. At the
310 beginning of each attempt the Handler invokes the
311 OnixS::CME::MDH::HandlerListener::onTcpRecovery callback
312 indicating begin of the TCP recovery procedure. Once all
313 missing packets are received and processed successfully, the
314 Handler ends the recovery procedure and notifies about that
315 through the OnixS::CME::MDH::HandlerListener::onEndOfTcpRecovery
318 The Handler may perform multiple attempts to recover missing
319 data through the TCP Recovery. Each time an attempt is made,
320 pair of the OnixS::CME::MDH::HandlerListener::onTcpRecovery and
321 the OnixS::CME::MDH::HandlerListener::onTcpRecovery callbacks
322 is invoked. If an attempt fails, the Handler uncovers a reason
323 of the failure as the OnixS::CME::MDH::RecoveryCompletionArgs::details
324 member of the OnixS::CME::MDH::RecoveryCompletionArgs parameter.