In normal flow, Handler logs all important aspects of its execution onto file system. Log files include also original market data processed by the Handler. This information is usually saved for analysis of non-standard situations which may occur during use of the Handler. However, it also can be used to reproduce normal Handler's behavior for a certain period of time.
Once Handler was executed with logging enabled, it's possible to use log files for further replay. First of all, logs must be backed up (copied to another location) or Handler's configuration must be updated to use another directory for new logs. This is because current implementation of the Handler doesn't support replay from the same folder in which new logs will be stored.
Afterwards, instance of OnixS::CME::MarketData::ReplayOptions class must be constructed and initialized with the logs to replay. The easiest way is to use one of OnixS::CME::MarketData::ReplayOptions class constructors which accepts channel identifier and path to the folder with logs to replay as a parameters:
This constructor will automatically gather all logs from the specified directory for the specified channel.
Alternatively, it's possible manually define list of log files to be replayed. Manually manipulating list of log files allows replaying log files whose names differ from names used by the Handler.
When configuring the options is accomplished, replay can be started. For this purpose, OnixS::CME::MarketData::Handler::start overload is to be called to start replaying. Replaying is performed by the Handler asynchronously in same way as regular execution flows. From client code point of view, there's no difference whether Handler processes market from the network or from log files.
To stop the Handler to replay log files, OnixS::CME::MarketData::Handler::stop member can be used.
When replay is accomplished Handler will call OnixS::CME::MarketData::ReplayListener::onReplayFinished member of the OnixS::CME::MarketData::ReplayListener class. To get notified about this and other replay-related events it's necessary to implement OnixS::CME::MarketData::ReplayListener class interface and supply an instance of the derived class to the Handler using OnixS::CME::MarketData::ReplayOptions::listener member.
Following example demonstrates how to replay log files backed up into 'replay' folder: