Skip to content

Commit f8442f6

Browse files
author
YOSHIDA Masanori
committed
Fix timing to set default application version ID at initiator side
- There are (at least) 2 threads at each host. - IO thread : Receives a message from an opposite and put it onto queue. - Application thread : Takes the message from the queue and processes it. - Original implementation - At initiator side, _Application thread_ sets default application version ID when receiving a first LOGON message. - IO thread needs default application version ID to be set to parse incoming messages. - If IO thread attempts to parse a message before Application thread sets default application version ID, it causes error. - Fixed version - At initiator side, _IO thread_ sets default application version ID when receiving a first LOGON message. - By the way, at acceptor side, IO thread sets default application version ID from the beginning.
1 parent 42bb050 commit f8442f6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

quickfixj-core/src/main/java/quickfix/mina/initiator/InitiatorIoHandler.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
import org.apache.mina.core.session.IoSession;
2323

2424
import quickfix.Message;
25+
import quickfix.MessageUtils;
2526
import quickfix.Session;
27+
import quickfix.SessionID;
28+
import quickfix.field.ApplVerID;
29+
import quickfix.field.DefaultApplVerID;
30+
import quickfix.field.MsgType;
2631
import quickfix.mina.AbstractIoHandler;
2732
import quickfix.mina.EventHandlingStrategy;
2833
import quickfix.mina.IoSessionResponder;
@@ -55,6 +60,17 @@ public void sessionCreated(IoSession session) throws Exception {
5560

5661
@Override
5762
protected void processMessage(IoSession protocolSession, Message message) throws Exception {
63+
if (message.getHeader().getString(MsgType.FIELD).equals(MsgType.LOGON)) {
64+
final SessionID sessionID = MessageUtils.getReverseSessionID(message);
65+
if (sessionID.isFIXT()) {
66+
if (message.isSetField(DefaultApplVerID.FIELD)) {
67+
final ApplVerID applVerID = new ApplVerID(message.getString(DefaultApplVerID.FIELD));
68+
quickfixSession.setTargetDefaultApplicationVersionID(applVerID);
69+
log.info("Setting DefaultApplVerID (" + DefaultApplVerID.FIELD + "="
70+
+ applVerID.getValue() + ") from Logon");
71+
}
72+
}
73+
}
5874
eventHandlingStrategy.onMessage(quickfixSession, message);
5975
}
6076

0 commit comments

Comments
 (0)