B2BITS FIX Antenna C++  2.27.1
FIX Session Acceptor

Table of Contents

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:

  1. Call one of the methods below to create a session:
    Session *createSession(
    Application *pApp, // a pointer to the Application that will process the incoming messages.
    const std::string& senderCompID, // SenderCompID of the session
    const std::string& targetCompID, // TargetCompID of the session
    FIXVersion ver, // FIX protocol version
    const SessionExtraParameters* pParam = NULL, // an optional session parameters, can be NULL
    const MessageStorageType storageType = persistentMM_storageType, // type of the message storage
    UnderlyingProtocol underlyingProtocolType = FIX_TCP); // session-level FIX protocol version
    Session *createSession(
    Application *pApp, // a pointer to the Application that will process the incoming messages.
    const std::string& senderCompID, // SenderCompID of the session
    const std::string& targetCompID, // TargetCompID of the session
    ProtocolID protocolID, // FIX protocol identifier
    FIXVersion ver, // FIX protocol version
    const SessionExtraParameters* pParam = NULL, // an optional session parameters, can be NULL
    const MessageStorageType storageType = persistentMM_storageType, // type of the message storage
    UnderlyingProtocol underlyingProtocolType = FIX_TCP); // session-level FIX protocol version
  2. 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>
    using namespace std;
    class Appl : public Engine::Application {
    // See "Application description" section
    };
    try {
    // initialization
    Appl appl;
    // creates a session for FIX 4.2
    &appl, "SENDER", "TARGET", Engine::FIX42);
    // establishes the session as Acceptor
    pSn->connect();
    // ... - business logic
    // terminates the FIX session
    pSn->disconnect();
    // it is vital to do this before the 'release' call
    pSn->registerApplication(NULL);
    // releases resources
    pSn->release();
    FixEngine::destroy();
    } catch(const Exception& ex) {
    cout << "EXCEPTION: " << ex.what() << endl;
    }

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:

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.