-
Notifications
You must be signed in to change notification settings - Fork 656
dynamic initiator session (QFJ-247) #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dynamic initiator session (QFJ-247) #157
Conversation
Hi @andyflury , thanks for the PR. Could you please document the intended usage of the new setting in https://github.com/quickfix-j/quickfixj/blob/master/quickfixj-core/src/main/doc/usermanual/usage/configuration.html ? Thanks, |
Just found this old JIRA issue... :) |
Hi Chris, thanks! I updated the documentation according to your suggestion |
protected final Logger log = LoggerFactory.getLogger(getClass()); | ||
private final Set<IoSessionInitiator> initiators = new HashSet<>(); | ||
|
||
private static final String SETTING_INACTIVE_SESSION = "Inactive"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Belongs in Initiator class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest this belongs in 2.1.0 given it's a feature not a bugfix.
Regarding the 'Inactive' flag - seems strange to have that for Dynamic Initiator and not the Dynamic Acceptor. Shouldn't they work similarly (SocketConnectHost
vs SocketAcceptHost
is already an annoyance to me)?
try { | ||
final Session quickfixSession = createSession(sessionID); | ||
initiatorSessions.put(sessionID, quickfixSession); | ||
if (!settings.isSetting(sessionID, SETTING_INACTIVE_SESSION) || !settings.getBool(sessionID, SETTING_INACTIVE_SESSION)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tests on this would be nice.
setSessions(initiatorSessions); | ||
} | ||
|
||
public void createDynamicSession(SessionID sessionID) throws ConfigError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again for a new feature it would be nice to see tests. For a considerable feature like a dynamic session some of the end-to-end / regression tests seem appropriate.
@philipwhiuk I'll be happy to provide a test case. Could you point me to an existing test case I could use as a basis for the new test case? |
I also moved the setting to the Initiator class, thanks for pointing this out |
Hi @andyflury , |
@philipwhiuk |
Hi, |
I can see test ready here. If this is sufficient enough for pull request it will be great. |
Hi @andyflury ,
I think the initiators are only removed from the set if the connector is stopped. Otherwise you will end up with double the initiators. |
Hi @chrjohn Glad to get Your comment up here. From what I understand in this this part in AbstractSocketInitiator.class: |
Hi @andyflury , I think you have an outdated version of the code. ;) Calling So I guess in your test you could just stop the connector and then re-create the sessions. |
Corrected the assertion and added one more to check , if initiators are removed.
No magic here I guess. Would that be sufficient? |
That should do the trick, thanks. |
Hi @chrjohn |
Thank You @chrjohn . Is there an option to merge the changes? |
Hi guys, Cheers, |
Great @chrjohn . Thanks for all Your support. I hope we ll get a change to talk again :) |
You're welcome. Thanks for the pull request! |
QFJ supports dynamic acceptor sessions, however the same does not exist for initiator sessions. This pull request would allow applications to createDynamic initiator sessions through AbstractSocketInitiator.createDynamicSession
Also, I added a new session level boolean setting "Inactive", that can be added to settings that should not start automatically when starting QuickFix. So this session can be started on demand with above new method. The constant SETTING_INACTIVE_SESSION would probably have to be moved somewhere else.
This might not be the proper way to do this, but it seems to be working.
Any comments are welcome