Creating FIX session acceptor
Refer to the section FIX Session to read about sessions-acceptors. When engine receives incoming FIX Logon message it tries to find corresponding session-acceptor i.e. session-acceptor with SenderCompID and TargetCompID equal to the TargetCompID and SenderCompID extracted from the received Logon message accordingly. If such session exists engine checks credentials and then links incoming message flow to the found session-acceptor. Otherwise engine treats this situation as "unregistered acceptor" (refer to the Unregistered acceptors for more information about "unregistered acceptor").
To create session-acceptor follow the 2-steps instruction below:
- Call one of the methods below to create a session:
Session *createSession(
Application *pApp,
const std::string& senderCompID,
const std::string& targetCompID,
FIXVersion ver,
const SessionExtraParameters* pParam = NULL,
const MessageStorageType storageType = persistentMM_storageType,
UnderlyingProtocol underlyingProtocolType = FIX_TCP);
Session *createSession(
Application *pApp,
const std::string& senderCompID,
const std::string& targetCompID,
ProtocolID protocolID,
FIXVersion ver,
const SessionExtraParameters* pParam = NULL,
const MessageStorageType storageType = persistentMM_storageType,
UnderlyingProtocol underlyingProtocolType = FIX_TCP);
- Call void Engine::Session::connect() to register session to the engine as acceptor. After this method is called engine starts accepting incoming connections with corresponding session ID (pair of SenderCompID and TargetCompID). For example:
#include <iostream>
#include <B2BITS_V12.h>
};
try {
Appl appl;
FixEngine::destroy();
} catch(const Exception& ex) {
cout << "EXCEPTION: " << ex.what() << endl;
}
Generic application interface.
Definition B2BITS_Application.h:82
Session * createSession(Application *pApp, const std::string &senderCompID, const std::string &targetCompID, FIXVersion appVer=NA, const SessionExtraParameters *pParam=NULL, const MessageStorageType storageType=default_storageType, UnderlyingProtocol underlyingProtocolType=FIX_TCP)
Creates a new FIX Session.
static FixEngine * init(InitParameters const ¶ms)
Initializes the Engine.
static FixEngine * singleton()
Returns an instance of this class.
FIX Session.
Definition B2BITS_Session.h:171
virtual void connect(SessionRole sessionRole=NA_SESSION_ROLE, const SessionBackupParameters *pSessionBackupParameters=NULL)=0
Establishes the FIX session.
virtual Application * registerApplication(Application *pNewApplication, unsigned int delay=300, int maxTries=-1)=0
Registers Application.
virtual void disconnect(bool forcefullyMarkAsTerminated=false)=0
Initiates disconnect of the session.
virtual long release() const
Decrements reference counter.
@ FIX42
FIX 4.2.
Definition B2BITS_PubEngineDefines.h:81
Unregistered acceptors
FIX Antenna automatically creates a session acceptor when a logon message is received and the corresponding pre-created session acceptor is not found. There are two ways to control this behavior:
- FIX Antenna property "CreateUnregisteredAcceptorSession" can be set to 'false' to disable automatic acceptor creation.
- If "CreateUnregisteredAcceptorSession" is set to 'true' the process of unregistered acceptors creation can be controlled by Sessions Manager. Refer to the Unregistered acceptors for more information about "unregistered acceptors".
Reconnect
According to the FIX protocol standard it is not the acceptor's responsibility to re-establish connection. When connection is terminated unexpectedly, the acceptor is moved the to "Wait for logon" state. It is expected that initiator on the remote side re-establishes telecommunication link and sends FIX Logon message continueing sequence numbers. When correct logon is received it is accepted by the engine and session acceptor continues working from the point of termination.
Disconnect
You can use the following methods to close connection (the process can also be called "terminate", "delete", "disconnect"):
If "forcefullyMarkAsTerminated" is true, then the session will be marked as correctly terminated and persistent information about it will not be used during the subsequent connections.
Release resources
Use the Engine::Session::release() method to release the allocated resources.
It is vital to call Engine::Session::registerApplication(NULL) before calling the release method.
It is vital to call the Engine::Session::release() method only once for the given session.
Send message
To send application-level messages, use the Engine::Session::put(Engine::FIXMessage *) method. There is no need to send session level messages (e.g. heartbeats), all session level messages are sent automatically when needed by the engine.