Search code examples
quickfixj

How to manage and reload multiple QuickFIX/J sessions independently?


I can configure multiple sessions in a single QuickFIX/J settings file and then start them all with a single SocketInitiator. But I would like to be able to modify the configuration of one or more sessions and then restart just those sessions without affecting any others.

I could do this by having multiple settings files and using one SocketInitiator per session. But it seems as though QuickFIX/J is not intended to be used this way. Would it cause me any problems?


Solution

  • It is perfectly fine to start up an Initiator per session. It is a matter of taste. In any case: having a separate Initiator per session is independent and will not affect the other sessions.

    If you want to follow the approach with a single Initiator then you could try to add/remove sessions dynamically via createDynamicSession()/removeDynamicSession(). There still is some manual work though.

    1. Find the Session that you want to reload. logout() and close() it.
    2. Call removeDynamicSession() for that Session.
    3. Get the settings for the SessionID that you want to reload from the running Initiator. Remove these from the running Initiator via removeSetting().
    4. Then reload the settings from the settings file for the needed Session and put them to the settings of the Initiator.
    5. Then call createDynamicSession() for the SessionID