Engine::Session* Engine::FixEngine::createSession(Engine::Application* apApp, const std::string& aSenderCompID, const std::string& aTargetCompID, Engine::FIXVersion aVer = FIX42, Engine::SessionExtraParameters* pParam = NULL, const Engine::MessageStorageType storageType = persistent_storageType)
Session state is stored on disk and can be restored after failure. The following information is stored for session:
Engine::Session* Engine::FixEngine::createSession(Engine::Application* apApp, const std::string& aSenderCompID, const std::string& aTargetCompID, Engine::FIXVersion aVer = FIX42, Engine::SessionExtraParameters* pParam = NULL, const Engine::MessageStorageType storageType = transient_storageType)
Session state is stored in memory, which highly increases performance. This is the recommended way in case when session is not required to provide fail-over by itself.
To convert the Engine::Session::State enum value to a string value, use the Engine::Session::state2string() method.
Both sides must maintains two values and control that they are in sync. There are two types of sequence numbers desync:
Both sequence numbers are started from 1 when session is created from scratch. After correct session termination sequence numbers are reset to 1. If connection is terminated non-gracefully then after restore sequence numbers continue. In fact a lot of service providers never reset sequence numbers during the day. The are also some, who reset sequence numbers once per week. There are several cases to handle such deviation from standard in FIX Antenna
The Engine::SessionExtraParameters::enableMessageRejecting_ parameter controlls if Message rejecting enabled or not (by default it is disabled). The configuration file's property MessageTimeToLive specifies how long session waits for connection restore (i.e. before reject the message). If connection is not restored during MessageTimeToLive interval - the session starts rejecting messages by calling Engine::Application::onMsgRejectEvent() for each rejected message.
It is vital to call the Engine::FixEngine::unregisterEventListener method before calling the Engine::FixEngine::destroy method.
To detect the exact type of the received event, use C++ RTTI or the Event::getType method.
For example:
class Listener : public Engine::EventListener { public: virtual void onNotification (const Engine::Notification &aNotification){ clog << "Notification: " << *aNotification.what() << endl << endl; } virtual void onWarning (const Engine::Warning &aWarning){ clog << "Warning: " << *aWarning.what() << endl << endl; } virtual void onError (const Engine::Error &aError){ clog << "Error: " << *aError.what() << endl << endl; } }; Listener listener; Engine::FixEngine::singleton()->registerEventListener(&listener); // ... - business logic // must be done before FixEngine::destroy() Engine::FixEngine::singleton()->unregisterEventListener(&listener); Engine::FixEngine::destroy();
1.5.6