Table of Contents |
---|
Description
...
In this example all sessions except "Sender1/Target1" will pass Session Qualifier as tag 9012 in Logon message.
...
.
FIX Antenna package Sample
The SessionQualifier sample application can be found in FA C++ package under "samples" directory.
The sample application registers two sessions with ids Acceptor1@Initiator@1 and Acceptor1@Initiator@2 on acceptor side. Then two Initiator sessions with ids Initiator@Acceptor1@1 and Initiator@Acceptor1@2 establish simultaneous connections to corresponding acceptor sessions and send order messages and receive responses.
At next step, initiator creates two sessions with ids Initiator@Acceptor2@1 and Initiator@Acceptor2@2 and connects to acceptor. Acceptor creates and registers corresponding sessions in onUnregisteredAcceptor handler. After having connections established, the initiator sessions send order messages and receive responses.
At the end all sessions are closed.
The information about received logon and logout messages as well as content of orders and execution reports messages can be seen in console. Logs are collected in directory "bin/logs".
To run sample just enter "sample/SessionQualifier/bin" directory and start run_*.bat on Windows or run.sh on Linux. To run debug version use corresponding command files with letter 'D' at the end. Note, the debug binaries are not included in the package, user needs to build them before running.
How to establish sessions with identical SenderCompID and TargetCompID
To establish several sessions with the same SenderCompId and TargetCompId, both Initiator and Acceptor should create several session objects which differ from each other by SessionQualifier property.
SessionQualifier property on Initiator side must be the same as SessionQualifier property of the corresponding session on acceptor side.
If you do not want an Initiator to pass the Session Qualifier in Logon message, you need to set the property for the Initiator:
Code Block | ||
---|---|---|
| ||
Engine::SessionExtraParameters params; params.logonMessageSessionQualifierTag_ = 0; |
...
Code Block | ||
---|---|---|
| ||
params.pSenderSubID_ = "YourSenderSubID"; |
Below is the code snippet that demonstrates how to do it.
Code Block | ||
---|---|---|
| ||
namespace { const char Acceptor2Name[] = "Acceptor2"; const char InitiatorName[] = "Initiator"; const char Q1[] = "1"; //Session Qualifier const char Q2[] = "2"; //Session Qualifier const char* LISTENER_IP = "127.0.0.1"; const int LISTENER_PORT = 9026; class InitiatorApp : public Engine::Application { //implementation }; } ... int main() { //init engine Engine::FixEngine::init("engine.properties"); //... Engine::SessionExtraParameters params; params.logonMessageSessionQualifierTag_ = 0; params.pSenderSubID_ = "SenderSubID_1"; // create two initiator sessions corresponding to the registered acceptor sessions and establish connections InitiatorApp app1, app2; Engine::Session* ps1 = Engine::FixEngine::singleton()->createSession( &app1, Engine::SessionId(InitiatorName, Acceptor2Name, Q1), Engine::FIX44, ¶ms); ps1->connect( 30, LISTENER_IP, LISTENER_PORT ); params.pSenderSubID_ = "SenderSubID_2"; Engine::Session* ps2 = Engine::FixEngine::singleton()->createSession( &app2, Engine::SessionId(InitiatorName, Acceptor2Name, Q2), Engine::FIX44, ¶ms); ps2->connect( 30, LISTENER_IP, LISTENER_PORT ); //... } |
As the result of running such code, following Logon messages will be sent:
Session Initiator/Acceptor2/SenderSubID_1:
...
Code Block |
---|
8=FIX.4.4|9=90|35=A|49=Initiator|56=Acceptor2|34=1|50=SenderSubID_2|52=20170926-15:56:45.284|98=0|108=30|10=116| |
Sample
The SessionQualifier sample application can be found in FA C++ package under "samples" directory.
The sample application registers two sessions with ids Acceptor1@Initiator@1 and Acceptor1@Initiator@2 on acceptor side. Then two Initiator sessions with ids Initiator@Acceptor1@1 and Initiator@Acceptor1@2 establish simultaneous connections to corresponding acceptor sessions and send order messages and receive responses.
At next step, initiator creates two sessions with ids Initiator@Acceptor2@1 and Initiator@Acceptor2@2 and connects to acceptor. Acceptor creates and registers corresponding sessions in onUnregisteredAcceptor handler. After having connections established, the initiator sessions send order messages and receive responses.
At the end all sessions are closed.
The information about received logon and logout messages as well as content of orders and execution reports messages can be seen in console. Logs are collected in directory "bin/logs".
...