...
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_1|52=20170926-15:56:45.237|98=0|108=30|10=113|
|
...
Session Initiator/Acceptor2/SenderSubID_2:
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| |