Creating sessions dynamically at startup

View: New views
3 Messages — Rating Filter:   Alert me  

Creating sessions dynamically at startup

by regis.dubois :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html
QuickFIX Support: http://www.quickfixengine.org/services.html


Hi,

I am trying to add a few session dynamically at startup:

SessionSettings settings = new SessionSettings(filename);
SessionID sess = new SessionID("FIX.4.4", "Sender", "Target");
settings.getSessions().Add(sess);
FileStoreFactory factory = new FileStoreFactory(settings);
FileLogFactory fileLogFactory = new FileLogFactory(settings);
QuickFix.MessageFactory messageFactory = new DefaultMessageFactory();
_qfFixAcceptor = new ThreadedSocketAcceptor(this, factory, settings,
fileLogFactory, messageFactory);
 _qfFixAcceptor.start();

Does not work.

Any idea what I am doing wrong?

Thanks,

Regis


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Quickfix-developers mailing list
Quickfix-developers@...
https://lists.sourceforge.net/lists/listinfo/quickfix-developers

Re: Creating sessions dynamically at startup

by Jaromír Šatánek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html
QuickFIX Support: http://www.quickfixengine.org/services.html


Hi Regis,

I am not quite sure whether it is exactly what you want, but following code should help:

The main idea is to construct dynamically configuration string of new session and from
this string new session can be created easily.

// configuration is a string containing text which is is typicaly content of QuickFix configuration file.
// You can build this string dynamically according to the session you want to create.
SessionSettings localSettings = new SessionSettings(new MemoryStream(
                    Encoding.Default.GetBytes(configuration)));

session = localSettings.getSessions()[0] as SessionID;                

FileStoreFactory storeFactory = new FileStoreFactory(localSettings);
MessageFactory messageFactory = new DefaultMessageFactory();                

FileLogFactoryEx fileLogFactory = new FileLogFactoryEx(localSettings, session);                               

fileLogFactory.OnSessionEvent += new OnSessionEventHandler(connector.fileLogFactory_OnSessionEvent);                
                
socketAcceptor = new SocketAcceptor(application, storeFactory, localSettings, fileLogFactory, messageFactory);    


Jaromir                

On Tue, Oct 27, 2009 at 2:57 PM, <regis.dubois@...> wrote:
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html
QuickFIX Support: http://www.quickfixengine.org/services.html


Hi,

I am trying to add a few session dynamically at startup:

SessionSettings settings = new SessionSettings(filename);
SessionID sess = new SessionID("FIX.4.4", "Sender", "Target");
settings.getSessions().Add(sess);
FileStoreFactory factory = new FileStoreFactory(settings);
FileLogFactory fileLogFactory = new FileLogFactory(settings);
QuickFix.MessageFactory messageFactory = new DefaultMessageFactory();
_qfFixAcceptor = new ThreadedSocketAcceptor(this, factory, settings,
fileLogFactory, messageFactory);
 _qfFixAcceptor.start();

Does not work.

Any idea what I am doing wrong?

Thanks,

Regis


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Quickfix-developers mailing list
Quickfix-developers@...
https://lists.sourceforge.net/lists/listinfo/quickfix-developers


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Quickfix-developers mailing list
Quickfix-developers@...
https://lists.sourceforge.net/lists/listinfo/quickfix-developers

Re: Creating sessions dynamically at startup

by Jaromír Šatánek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html
QuickFIX Support: http://www.quickfixengine.org/services.html


3 more comments on this:

To add new session to sessions that are specified in the configuration file it is possible to copy content of the file into string and then append configuration of new session (that should be created dynamically) and then create SessionSettings object from the result stream (as shown in my first reply). I used this solution because I needed to create Initiator / Acceptor object for each session specified in the configuration file.

Or maybe it is possible to use set method from SessionSettings class and pass the new session id to this method. But I have not tested this.

There are two problems in the code that was sent by Regis:
1) It is not clear whether settings.getSessions() returns reference to internal structure that is used by SessionSettings class.
2)Settings of the session that was added was not specified.

Jaromir

2009/10/27 Jaromír Šatánek <mira.satanek@...>
Hi Regis,

I am not quite sure whether it is exactly what you want, but following code should help:

The main idea is to construct dynamically configuration string of new session and from
this string new session can be created easily.

// configuration is a string containing text which is is typicaly content of QuickFix configuration file.
// You can build this string dynamically according to the session you want to create.
SessionSettings localSettings = new SessionSettings(new MemoryStream(
                    Encoding.Default.GetBytes(configuration)));

session = localSettings.getSessions()[0] as SessionID;                

FileStoreFactory storeFactory = new FileStoreFactory(localSettings);
MessageFactory messageFactory = new DefaultMessageFactory();                

FileLogFactoryEx fileLogFactory = new FileLogFactoryEx(localSettings, session);                               

fileLogFactory.OnSessionEvent += new OnSessionEventHandler(connector.fileLogFactory_OnSessionEvent);                
                
socketAcceptor = new SocketAcceptor(application, storeFactory, localSettings, fileLogFactory, messageFactory);    


Jaromir                

On Tue, Oct 27, 2009 at 2:57 PM, <regis.dubois@...> wrote:
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html
QuickFIX Support: http://www.quickfixengine.org/services.html


Hi,

I am trying to add a few session dynamically at startup:

SessionSettings settings = new SessionSettings(filename);
SessionID sess = new SessionID("FIX.4.4", "Sender", "Target");
settings.getSessions().Add(sess);
FileStoreFactory factory = new FileStoreFactory(settings);
FileLogFactory fileLogFactory = new FileLogFactory(settings);
QuickFix.MessageFactory messageFactory = new DefaultMessageFactory();
_qfFixAcceptor = new ThreadedSocketAcceptor(this, factory, settings,
fileLogFactory, messageFactory);
 _qfFixAcceptor.start();

Does not work.

Any idea what I am doing wrong?

Thanks,

Regis


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Quickfix-developers mailing list
Quickfix-developers@...
https://lists.sourceforge.net/lists/listinfo/quickfix-developers



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Quickfix-developers mailing list
Quickfix-developers@...
https://lists.sourceforge.net/lists/listinfo/quickfix-developers