forwardStrongly Typed Messages   Table of ContentLow Latency Best Practicesforward
Replaying Log Files
Using Logs to Replay Market Data

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.

Note Note

TraceSwitch level should be set at least at Info level to log incoming packets for log replay.

Afterwards, instance of ReplayOptions class must be constructed and initialized with the pat to log to replay.

When configuring the options is accomplished, replay can be started.

Note Note

Handler fires appropriate events as soon as market data is received from the network and processed. However, since CME environment spreads market data with different frequency which depends on live market activity, there're delays of different duration between fired events. When log file is replayed, Handler does not do any pauses and fires corresponding events as soon as data is retrieved from the log file.

When replay is accomplished Handler will call ReplayFinished event will be raised.

Note Note

When market data is being replayed, ReceivingTime parameter of different callbacks will contain time of corresponding log file entry. That's the value returned represents original time when market data message was obtained from the network.

Currently, log replay must be run with the same set of Handler's settings which were originally used.

Example

Following example demonstrates how to replay log file 'Log.txt' folder:

C#
string fileName = 'Log.txt';

Handler handler = new Handler("310");
handler.ReplayFinished += new EventHandler<EventArgs>(handler_ReplayFinished);
handler.ReplayError += new EventHandler<Handler.ReplayErrorEventArgs>(handler_ReplayError);

handler_.Start(BooksMaintenanceOptions.All, new ReplayOptions(fileName) { DelayBetweenMessages = 0 });

void handler_ReplayError(object sender, Handler.ReplayErrorEventArgs e)
{
    Console.WriteLine("Replay error: " + e.Description);
}

void handler_ReplayFinished(object sender, EventArgs e)
{
    Console.WriteLine("Replay finished");
}