B2BITS FIX Antenna C++ 2.32.0
Loading...
Searching...
No Matches
FIX Session Acceptor

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;
    }
    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 &params)
    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
    STL namespace.

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.