OnixS C++ CME MDP Premium Market Data Handler  5.8.9
API Documentation
HandlerListener.h
Go to the documentation of this file.
1 // Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2 //
3 // This software owned by Onix Solutions Limited [OnixS] and is
4 // protected by copyright law and international copyright treaties.
5 //
6 // Access to and use of the software is governed by the terms of the applicable
7 // OnixS Software Services Agreement (the Agreement) and Customer end user license
8 // agreements granting a non-assignable, non-transferable and non-exclusive license
9 // to use the software for it's own data processing purposes under the terms defined
10 // in the Agreement.
11 //
12 // Except as otherwise granted within the terms of the Agreement, copying or
13 // reproduction of any part of this source code or associated reference material
14 // to any other location for further reproduction or redistribution, and any
15 // amendments to this copyright notice, are expressly prohibited.
16 //
17 // Any reproduction or redistribution for sale or hiring of the Software not in
18 // accordance with the terms of the Agreement is a violation of copyright law.
19 //
20 
21 #pragma once
22 
23 #include <string>
24 
26 
28 
29 /// Collection of statuses of recovery completion.
31 {
32  enum Enum
33  {
34  /// Recovery accomplished successfully.
36 
37  /// Recovery failed and no further
38  /// attempts to recover will be made.
40 
41  /// Identifies incomplete recovery.
42  /// Used to identify restart of recovery,
43  /// when new loop of recovery data is detected
44  /// and thus recovery must be done from scratch.
45  Incomplete
46  };
47 };
48 
49 /// Gathers information about the recovery completion.
51 {
52 public:
53  /// Initializes as blank instance.
55 
56  /// Initializes with given details.
57  RecoveryCompletionArgs(RecoveryCompletionStatus::Enum status, const std::string& message = std::string())
58  : status_(status)
59  , message_(message)
60  {
61  }
62 
63  /// Indicates completion status of the recovery.
65  {
66  return status_;
67  }
68 
69  /// Human readable description of recovery completion.
70  /// In case of failure may include failure reason.
71  const std::string& details() const
72  {
73  return message_;
74  }
75 
76  /// Associates human readable message
77  /// with recover completion event.
78  void details(const std::string& message)
79  {
80  message_ = message;
81  }
82 
83 private:
85  std::string message_;
86 };
87 
88 /// Collection of issues Handler may
89 /// report during market data processing.
91 {
92  enum Enum
93  {
94  /// Identifies network connection failure.
96 
97  /// Source reported this issue will
98  /// function in reduced capacity.
99  ///
100  /// For example, if feed engine fails to
101  /// configure feed to use socket buffer as
102  /// specified by Handler settings, feed will
103  /// continue functioning but in reduced capacity.
105 
106  /// Indicates data reception failure.
108 
109  /// Indicates data receive timeout.
111 
112  /// Indicates data processing failure.
114 
115  /// Indicates internal queue overflow.
117 
118  /// Indicates error in data sequence.
120 
121  /// Operation performed by the Handler failed.
123 
124  /// Operation performed by the Handler did not
125  /// accomplish within the time allocated for it.
127 
128  /// Market data replay failed.
129  ReplayFailure
130  };
131 };
132 
133 /// Gathers information about the issue Handler
134 /// may experience while processing market data.
136 {
137 public:
138  /// Initializes issue with provided attributes.
139  IssueArgs(Issue::Enum id, const std::string& source, const std::string& description)
140  : id_(id)
141  , source_(source)
142  , description_(description)
143  {
144  }
145 
146  /// Issue identifier.
147  Issue::Enum id() const
148  {
149  return id_;
150  }
151 
152  /// Source of the issue.
153  const std::string& source() const
154  {
155  return source_;
156  }
157 
158  /// Human readable description of the issue.
159  const std::string& description() const
160  {
161  return description_;
162  }
163 
164 private:
165  Issue::Enum id_;
166  const std::string& source_;
167  const std::string& description_;
168 
169  IssueArgs(const IssueArgs&);
170  IssueArgs& operator=(const IssueArgs&);
171 };
172 
173 /// Warning arguments.
175 
176 /// Error arguments.
178 
180 
181 /// Events raised by Handler while processing market data.
183 {
184  /// Handler is has started to process market data.
185  virtual void onStarted(Handler&) {}
186 
187  /// Invoked when Handler has stopped market data processing.
188  virtual void onStopped(Handler&) {}
189 
190  /// Download or replay of Security Definition(d) messages is started.
191  virtual void onInstrumentRecovery(Handler&) {}
192 
193  /// Download or replay of Security Definition(d) messages is finished.
195 
196  /// Handler started recovering order books from snapshots.
197  ///
198  /// Handler switches to this state when it joins the market and the
199  /// initial books state is built from MarketDataSnapshotFullRefresh
200  /// (MsgType=W) messages or when the TCP Recovery is not used and the
201  /// message sequence number gap is detected, so the book state should
202  /// be re-built from MarketDataSnapshotFullRefresh (MsgType=W) messages
203  /// again.
204  ///
205  /// It should be assumed at this point that all books maintained
206  /// in the Handler may no longer have the correct, latest state
207  /// maintained by CME, so they are cleared.
208  virtual void onMarketRecovery(Handler&) {}
209 
210  /// Handler accomplished recovering order books from snapshots.
211  ///
212  /// Handler switches to this state when the latest books state is
213  /// restored from MarketDataSnapshotFullRefresh (MsgType=W) messages
214  /// (all snapshot data is retrieved).
215  ///
216  /// It should be assumed at this point that all books maintained in
217  /// the Handler have the correct, latest state maintained by CME.
219 
220  /// Handler spawned recovery of lost packets over TCP feed.
221  virtual void onTcpRecovery(Handler&) {}
222 
223  /// Handler accomplished recovery of lost packets over TCP feed.
225 
226  /// Handler resumed real-time processing of
227  /// market data received over incremental feeds.
228  virtual void onRealtimeProcessing(Handler&) {}
229 
230  /// Handler suspended real-time processing of
231  /// market data received over incremental feeds.
233 
234  /// Non-critical issue occurred while Handler is
235  /// processing market data. Handler will handle
236  /// an issue by itself, thus no special handling
237  /// is required for the case. Supplied parameters
238  /// exposes details information on the issue.
239  virtual void onWarning(Handler&, const WarningArgs&) {}
240 
241  /// Error occurred while Handler is processing market
242  /// data. In contrast to warnings, given issue indicates
243  /// the fact Handler fell into a conditions which are not
244  /// supposed to take place (for example, book update failed
245  /// due to corrupted data). Handler will handle an issue by
246  /// itself, thus no special handling is required for the case.
247  virtual void onError(Handler&, const ErrorArgs&) {}
248 };
249 
250 inline std::ostream& operator<<(std::ostream& stream, const IssueArgs& args)
251 {
252  return stream << args.description();
253 }
254 
Gathers information about the issue Handler may experience while processing market data...
Indicates data processing failure.
Indicates data receive timeout.
RecoveryCompletionStatus::Enum status() const
Indicates completion status of the recovery.
RecoveryCompletionArgs()
Initializes as blank instance.
Recovery accomplished successfully.
void details(const std::string &message)
Associates human readable message with recover completion event.
Issue::Enum id() const
Issue identifier.
virtual void onEndOfMarketRecovery(Handler &, const RecoveryCompletionArgs &)
Handler accomplished recovering order books from snapshots.
virtual void onInstrumentRecovery(Handler &)
Download or replay of Security Definition(d) messages is started.
Recovery failed and no further attempts to recover will be made.
IssueArgs(Issue::Enum id, const std::string &source, const std::string &description)
Initializes issue with provided attributes.
Identifies network connection failure.
Encapsulates all the machinery related with market data processing from CME Market Data Platform...
Definition: Handler.h:55
Indicates data reception failure.
virtual void onWarning(Handler &, const WarningArgs &)
Non-critical issue occurred while Handler is processing market data.
Collection of issues Handler may report during market data processing.
virtual void onRealtimeProcessing(Handler &)
Handler resumed real-time processing of market data received over incremental feeds.
#define ONIXS_CMEMDH_EXPORTED_CLASS_DECL(typeName)
Definition: Bootstrap.h:35
#define ONIXS_CMEMDH_LTWT
Definition: Bootstrap.h:46
virtual void onStopped(Handler &)
Invoked when Handler has stopped market data processing.
IssueArgs WarningArgs
Warning arguments.
Source reported this issue will function in reduced capacity.
Indicates internal queue overflow.
Indicates error in data sequence.
Collection of statuses of recovery completion.
virtual void onMarketRecovery(Handler &)
Handler started recovering order books from snapshots.
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:67
Gathers information about the recovery completion.
virtual void onEndOfRealtimeProcessing(Handler &)
Handler suspended real-time processing of market data received over incremental feeds.
virtual void onError(Handler &, const ErrorArgs &)
Error occurred while Handler is processing market data.
std::ostream & operator<<(std::ostream &stream, const IssueArgs &args)
RecoveryCompletionArgs(RecoveryCompletionStatus::Enum status, const std::string &message=std::string())
Initializes with given details.
#define ONIXS_CMEMDH_EXPORTED
Definition: Compiler.h:160
Operation performed by the Handler failed.
virtual void onTcpRecovery(Handler &)
Handler spawned recovery of lost packets over TCP feed.
virtual void onEndOfInstrumentRecovery(Handler &, const RecoveryCompletionArgs &)
Download or replay of Security Definition(d) messages is finished.
const std::string & details() const
Human readable description of recovery completion.
Operation performed by the Handler did not accomplish within the time allocated for it...
virtual void onEndOfTcpRecovery(Handler &, const RecoveryCompletionArgs &)
Handler accomplished recovery of lost packets over TCP feed.
Events raised by Handler while processing market data.
virtual void onStarted(Handler &)
Handler is has started to process market data.
const std::string & source() const
Source of the issue.
const std::string & description() const
Human readable description of the issue.
IssueArgs ErrorArgs
Error arguments.
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:68