Shows how to warm and reuse a product definition cache. A first Handler runs in receiveProductDefinitionsOnly mode to download the definitions for all subscriptions and store them in the cache directory; two further Handlers then start simultaneously and load the cached definitions instead of downloading them again.
#include "../Common/Defaults.h"
#include "../Common/ServiceEventTracer.h"
#include "../Common/Utils.h"
#include <cstdlib>
#ifndef _WIN32
# include <pthread.h>
# include <csignal>
# include <cstdio>
# include <vector>
#endif
int main(int , char** )
{
try
{
introduceMyself("Product Definition Cache");
handler.bindFeedEngine(feedEngine);
ServiceEventTracer serviceEventTracer;
serviceEventTracer.attachTo(handler);
);
);
subscriptions.insert(ipeGasOilFutures);
subscriptions.insert(brentFutures);
handler.start(subscriptions);
{
CurrentThread::sleep(1000);
}
handler1.bindFeedEngine(feedEngine);
ServiceEventTracer serviceEventTracer1;
serviceEventTracer1.attachTo(handler1);
handler2.bindFeedEngine(feedEngine);
ServiceEventTracer serviceEventTracer2;
serviceEventTracer2.attachTo(handler2);
handler1.start(ipeGasOilFutures);
handler2.start(brentFutures);
while (
)
{
CurrentThread::sleep(1000);
}
handler1.stop();
handler2.stop();
std::cout << "Done." << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Error: " << ex.what() << std::endl;
return EXIT_FAILURE;
}
catch (...)
{
std::cerr << "Unknown exception." << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}