OnixS ICE iMpact Multicast Price Feed Handler C++ library 8.18.0
Users' manual and API documentation
Loading...
Searching...
No Matches
Receive Product Definitions Only Sample

Runs the Handler in receiveProductDefinitionsOnly mode: it downloads the product definitions for the requested subscriptions and stops automatically once they have all been received, without processing live market data.

Source code

#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 /*argc*/, char** /*argv*/)
{
try
{
introduceMyself("Receive Product Definitions Only");
FeedEngineSettings feedEngineSettings;
FeedEngine feedEngine(feedEngineSettings);
HandlerSettings handlerSettings;
// For most of Linux operating systems it would be
// better to define following parameter to be able to
// successfully receive market data from multicast feeds.
handlerSettings.networkInterface = NETWORK_INTERFACE;
// Let's activate logging to get data for support.
handlerSettings.logLevel = LogLevels::Debug;
handlerSettings.logDirectory = LOG_DIRECTORY;
handlerSettings.logFileNamePrefix = LOG_FILE_NAME_PREFIX;
// By default, license is stored in lib folder of the distribute
// package. Instead of copying, let's use original file.
handlerSettings.licenseDirectory = LICENSE_DIRECTORY;
// Allow only product definition receiving.
handlerSettings.receiveProductDefinitionsOnly = true;
// Primary settings - connectivity configuration.
handlerSettings.connectivityConfiguration = AP1_C10Y_FILE;
// Constructs handler with custom license root and enabled logging.
// It will be used to download the product definitions for all market
// subscriptions.
Handler handler(handlerSettings);
// Binds the handler to the feed engine.
handler.bindFeedEngine(feedEngine);
// Traces all service events coming from handlers.
ServiceEventTracer serviceEventTracer;
serviceEventTracer.attachTo(handler);
// Making subscription.
MarketSubscriptions subscriptions;
MarketSubscription brentFutures(
);
subscriptions.insert(brentFutures);
// Start the Handler to download product definitions
// for all market subscriptions.
handler.start(subscriptions);
while (handler.state() != HandlerStates::Stopped)
{
CurrentThread::sleep(1000);
}
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;
}