I am using QuickFIX/J with Spring esanchezros/quickfixj-spring-boot-starter and I am trying to add a new session during the application runtime.
- I create a Bean to initialise the ThreadSocketAcceptor then I add a SessionProvider. The application listens all the connections for FIX.4.2 sessions.
ThreadedSocketAcceptor threadedSocketAcceptor = new ThreadedSocketAcceptor(serverApplication, serverMessageStoreFactory, serverSessionSettings,
serverLogFactory, serverMessageFactory);
SessionID anySession = new SessionID(BEGINSTRING_FIX42, WILDCARD, WILDCARD);
threadedSocketAcceptor.setSessionProvider(
new InetSocketAddress("0.0.0.0", 9878),
new DynamicAcceptorSessionProvider(serverSessionSettings, anySession, serverApplication, serverMessageStoreFactory,
serverLogFactory, serverMessageFactory)
);
- The application is running and during the runtime, I build the session settings and add the dynamic session
DefaultSessionFactory defaultSessionFactory = new DefaultSessionFactory(serverApplication, serverMessageStoreFactory, serverLogFactory, serverMessageFactory);
SessionSettings sessionSettings = buildSessionSettings(session.get(), sessionID);
Session quickfixSession = defaultSessionFactory.create(sessionID, sessionSettings);
threadedSocketAcceptor.addDynamicSession(quickfixSession);
- OnLogon, I send a query to my database to know if the session is stored in my own table. If it is not present, I log out the session.
[4.] Update the session settings : removeDynamicSession (with logout and close) then addDynamicSession.
Is it the good way to proceed? Because, I can't update the settings for my session.