有问题与QuickFixJ。问题是我无法正确发送登录消息。另外,我很难理解如何设置消息流。我不是想要执行交易,只是检索市场数据。
错误:
20140123-22:55:56: No responder, not sending message:
以下是我的所有细节:
传入: 猫来了/ *
8=FIXT.1.19=11035=A34=149=REDACTED-MD52=20140123-22:55:56.37256=NDXMD98=0108=30141=Y553=REDACTED100554=REDACTED1137=910=231?220140123-22:55:56.470
传出:
20140123-22:55:50: Session FIXT.1.1:REDACTED-MD->NDXMD schedule is weekly, SUN 00:00:00-UTC - FRI 00:00:00-UTC
20140123-22:55:50: Created session: FIXT.1.1:REDACTED-MD->NDXMD
20140123-22:55:53: Initiated logon request
20140123-22:55:56: No responder, not sending message: 8=FIXT.1.19=11035=A34=149=REDACTED-MD52=20140123-22:55:56.37256=NDXMD98=0108=30141=Y553=REDACTED100554=REDACTED1137=910=231
8=FIXT.1.19=8135=A34=149=REDACTED-MD52=20140123-22:55:52.64356=NDXMD98=0108=30141=Y1137=910=114
8=FIXT.1.19=8335=549=NDXMD56=REDACTED-MD52=20140123-22:55:53.75134=158=Missing field. Type 55310=054
8=FIXT.1.19=11035=A34=149=REDACTED-MD52=20140123-22:55:56.37256=NDXMD98=0108=30141=Y553=REDACTED100554=REDACTED1137=910=231
我的标准是: Ĵ
an 23, 2014 10:55:37 PM REDACTED.REDACTEDMain main
INFO: REDACTED startup
Jan 23, 2014 10:55:49 PM quickfix.SessionSchedule <init>
INFO: [FIXT.1.1:REDACTEDB-MD->NDXMD] weekly, SUN 00:00:00-UTC - FRI 00:00:00-UTC
Successfully called onCreate for sessionId : FIXT.1.1:REDACTEDB-MD->NDXMD
Jan 23, 2014 10:55:50 PM quickfix.mina.NetworkingOptions logOption
INFO: Socket option: SocketTcpNoDelay=true
Jan 23, 2014 10:55:50 PM quickfix.mina.NetworkingOptions logOption
INFO: Socket option: SocketSynchronousWrites=false
Jan 23, 2014 10:55:50 PM quickfix.mina.NetworkingOptions logOption
INFO: Socket option: SocketSynchronousWriteTimeout=30000
Jan 23, 2014 10:55:51 PM quickfix.mina.initiator.IoSessionInitiator <init>
INFO: [FIXT.1.1:REDACTEDB-MD->NDXMD] [web-fix.REDACTED.com/194.107.REDACTED:7170]
Jan 23, 2014 10:55:51 PM quickfix.mina.SessionConnector startSessionTimer
INFO: SessionTimer started
Sleeping for start() ....
Jan 23, 2014 10:55:51 PM quickfix.mina.initiator.InitiatorIoHandler sessionCreated
INFO: MINA session created for FIXT.1.1:REDACTEDB-MD->NDXMD: local=/10.215.87.15:34197, class org.apache.mina.transport.socket.nio.SocketSessionImpl, remote=web-fix.REDACTED.com/194.107.REDACTED:7170
Inside toAdmin
Message: 8=FIXT.1.19=8135=A34=149=REDACTEDB-MD52=20140123-22:55:52.64356=NDXMD98=0108=30141=Y1137=910=114
XML: <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<message>
<header>
<field tag="8"><![CDATA[FIXT.1.1]]></field>
<field tag="9"><![CDATA[81]]></field>
<field tag="34"><![CDATA[1]]></field>
<field tag="35"><![CDATA[A]]></field>
<field tag="49"><![CDATA[REDACTEDB-MD]]></field>
<field tag="52"><![CDATA[20140123-22:55:52.643]]></field>
<field tag="56"><![CDATA[NDXMD]]></field>
</header>
<body>
<field tag="98"><![CDATA[0]]></field>
<field tag="108"><![CDATA[30]]></field>
<field tag="141"><![CDATA[Y]]></field>
<field tag="1137"><![CDATA[9]]></field>
</body>
<trailer>
<field tag="10"><![CDATA[114]]></field>
</trailer>
</message>
Header: quickfix.fixt11.Message$Header@10f268de
Trailer: quickfix.Message$Trailer@1ac2cf83
Jan 23, 2014 10:55:53 PM quickfix.mina.AbstractIoHandler messageReceived
SEVERE: Invalid message: Can't determine ApplVerID for message
Jan 23, 2014 10:55:53 PM quickfix.Session disconnect
INFO: [FIXT.1.1:REDACTEDB-MD->NDXMD] Disconnecting: IO Session closed
Successfully logged out for sessionId : FIXT.1.1:REDACTEDB-MD->NDXMD
Inside toAdmin
Message: 8=FIXT.1.19=11035=A34=249=REDACTEDB-MD52=20140123-22:55:56.37256=NDXMD98=0108=30141=Y553=REDACTED100554=REDACTED1137=910=232
XML: <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<message>
<header>
<field tag="8"><![CDATA[FIXT.1.1]]></field>
<field tag="9"><![CDATA[110]]></field>
<field tag="34"><![CDATA[2]]></field>
<field tag="35"><![CDATA[A]]></field>
<field tag="49"><![CDATA[REDACTEDB-MD]]></field>
<field tag="52"><![CDATA[20140123-22:55:56.372]]></field>
<field tag="56"><![CDATA[NDXMD]]></field>
</header>
<body>
<field tag="98"><![CDATA[0]]></field>
<field tag="108"><![CDATA[30]]></field>
<field tag="141"><![CDATA[Y]]></field>
<field tag="553"><![CDATA[REDACTED100]]></field>
<field tag="554"><![CDATA[REDACTED]]></field>
<field tag="1137"><![CDATA[9]]></field>
</body>
<trailer>
<field tag="10"><![CDATA[232]]></field>
</trailer>
</message>
Header: quickfix.fixt11.Message$Header@49f8d077
Trailer: quickfix.Message$Trailer@6e3e5a91
Logon Message Sent : false
我的问题来源是: MAIN:
try {
Application app = new AFIX();
SessionSettings settings = new SessionSettings("sessionSettings.txt");
FileStoreFactory fileStoreFactory = new FileStoreFactory(settings);
FileLogFactory logFactory = new FileLogFactory(settings);
MessageFactory messageFactory = new DefaultMessageFactory();
SocketInitiator socketInitiator = new SocketInitiator(app,
fileStoreFactory, settings, logFactory, messageFactory);
socketInitiator.start();
try {
System.out.println("Sleeping for start() ....");
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
SessionID sessionId = socketInitiator.getSessions().get(0);
AFIX.sendLogonRequest(sessionId);
int i = 0;
do {
try {
Thread.sleep(1000);
System.out.println(socketInitiator.isLoggedOn());
} catch (InterruptedException e) {
e.printStackTrace();
}
i++;
} while ((!socketInitiator.isLoggedOn()) && (i < 25));
} catch (ConfigError e) {
... ... ...
public static void sendLogonRequest(SessionID sessionId)
throws SessionNotFound {
quickfix.fixt11.Logon logon = new quickfix.fixt11.Logon();
quickfix.Message.Header header = logon.getHeader();
header.setField(new quickfix.field.BeginString("FIXT.1.1"));
header.setField(new quickfix.field.MsgType("A"));
Properties p = loadProperties();
logon.set(new quickfix.field.Username(p.getProperty("username")));
logon.set(new quickfix.field.Password(p.getProperty("password")));
logon.set(new quickfix.field.HeartBtInt(30));
logon.set(new quickfix.field.ResetSeqNumFlag(true));
logon.set(new quickfix.field.DefaultApplVerID("9"));
logon.set(new quickfix.field.EncryptMethod(0));
boolean sent = Session.sendToTarget(logon, sessionId);
System.out.println("Logon Message Sent : " + sent);
}
最后我的设置:
cat sessionSettings.txt
[DEFAULT]# Settings which apply to all the Sessions.
ConnectionType=initiator
LogonTimeout=30
ReconnectInterval=30
UseDataDictionary=Y
ResetOnLogon=Y
FileStorePath=incoming
FileLogPath=outgoing
[SESSION]# Settings specifically for one session
BeginString=FIXT.1.1
DefaultApplVerID=9
AppDataDictionary=FIX50.xml
SenderCompID=REDACTED-MD
TargetCompID=NDXMD
StartDay=sunday
EndDay=friday
StartTime=00:00:00
EndTime=00:00:00
HeartBtInt=30
CheckLatency=N
MaxLatency=240
SocketConnectPort=7170
SocketConnectHost=web-fix.REDACTED.com
UseDataDictionary=Y
DataDictionary=lib/quickfixj-all-1.5.3.jar!/FIX50SP2.xml
非常感谢任何帮助!
答案 0 :(得分:4)
(这是一个接受者,不是发起者,但它并不重要。)
您会注意到它不会手动创建登录消息并发送它。引擎会在initiator.start
(或acceptor.start
)时自动执行此操作。 (请参阅您的日志:“无响应者,不发送消息” - 这是您的手动登录行尝试在引擎完成正确登录之前发送)。
基本上,在socketInitiator.start();
和块的结尾之间取出所有代码,然后删除它的。只是放入某种睡眠动作(比如等待控制台输入或其他东西)。
你可能还有其他问题,但那是我现在看到的问题。
答案 1 :(得分:2)
发送要覆盖从Application继承的toAdmin方法的凭据 首先检查标头中保存的MsgType,确保它是登录消息。然后,您可以在该点将相关字段添加到消息中。然后,quickfix引擎将发送包含您所需内容的消息。
如果您在登录之前等待做某事,请实施MessageCracker界面。
从Application重写fromApp方法并在msg上调用crack。然后,您将覆盖onLogon方法表单MessageCracker,您可以从该点运行其余代码,因为您将知道您已登录。
答案 2 :(得分:1)
适用于FIXT.1.1
要解决: 无法确定消息的ApplVerID
在你的toAdmin()方法中添加以下行, Session.lookupSession(sessionId).setTargetDefaultApplicationVersionID(new ApplVerID(&#34; 9&#34;));
这将解决问题,并且注销消息将传递给fromAdmin()方法