# Here is my settings.cfg file:
# Thank you.Here is what i tried.My settings.cfg file
[DEFAULT]
# Settings which apply to all the Sessions.
ConnectionType=initiator
LogonTimeout=30
ReconnectInterval=20
ResetOnLogon=Y
FileLogPath=C:\Work\QuickFIXJ\logs
FileStorePath=C:\Work\QuickFIXJ\logs
[SESSION]
# Settings specifically for one session
BeginString=FIX.4.4
SenderCompID=XYZ
TargetCompID=TYZ
TimeZone=Asia/Tokyo
StartTime=16:00:00
EndTime=13:30:00
HeartBtInt=60
SocketConnectPort=7200
SocketConnectHost=123.123.123.123
UseDataDictionary=Y
DataDictionary=C:\Work\QuickFIXJ\datadictionary\FIX44.xml
[GATEWAY]
Port=4444
[TRANSPORT]
Port=4444
//initiator code:
public class TestQuickFixJConnectivity {
public static void main(String[] args) {
SocketInitiator socketInitiator = null;
try {
SessionSettings sessionSettings = new SessionSettings("C:\\Work\\QuickFixJ\\sessionSettings.txt");
Application application = new TestApplicationImpl();
FileStoreFactory fileStoreFactory = new FileStoreFactory(sessionSettings);
FileLogFactory logFactory = new FileLogFactory(sessionSettings);
MessageFactory messageFactory = new DefaultMessageFactory();
socketInitiator = new SocketInitiator(application,
fileStoreFactory, sessionSettings, logFactory,
messageFactory);
socketInitiator.start();
SessionID sessionId = socketInitiator.getSessions().get(0);
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 < 30));
} catch (ConfigError e) {
e.printStackTrace();
} catch (SessionNotFound e) {
e.printStackTrace();
} catch (Exception exp) {
exp.printStackTrace();
} finally {
if (socketInitiator != null) {
socketInitiator.stop(true);
}
}
}
private static void sendLogonRequest(SessionID sessionId) throws SessionNotFound {
Logon logon = new Logon();
Message msg=new Message();
Header header = msg.getHeader();
logon.set(new HeartBtInt(60));
logon.set(new ResetSeqNumFlag(true));
header.setField(new BeginString("FIX.4.4"));
header.setField(new MsgType("AP"));
header.setField(new SenderCompId("XYZ"));
header.setField(new TagetCompId("TYZ"));
header.setField(new ResetSeqNumFlag(true));
//here i m setting all the fields in the csv report .
msg.setField(705,new SortQty(""));
// ....
//below statement returning false
boolean sent = Session.sendToTarget(msg, sessionId);
System.out.println("Logon Message Sent : " + sent);
}
}
請在下面找到我的意見:
在事件日誌中我看到了作爲創建的會話:和消息我正在嘗試發送。另外我可以看到發件人序列號在日誌中增加。
Messages.log和header.logs是空白的,body.log中有我正在發送的消息。
當我嘗試運行代碼時,onCreate和ToApp也被調用。
我想知道我是否已成功發送消息?
也boolean sent = Session.sendToTarget(msg, sessionId); is returning false
。
我看不到在我的代碼中執行ToAdmin和FromAdmin。另外我是否也需要編寫接受者代碼,或者只是發起者代碼就可以。我正在使用的DataDictionary有所有的字段集,但我不確定當我嘗試執行代碼時它是否被QuickFixJ使用。
請告知這是怎麼回事?
謝謝:)我在我的代碼所做的更改,試圖發送消息。 。我的代碼不會調用toadmin和從管理員,它只是調用toapp ...是有必要在發送應用程序消息(這裏我試圖發送msgtype = AP)之前發送登錄msgtype = A。我怎樣才能知道我的郵件是否成功發送。 – Kini
「如果登錄成功,它會開始心跳」我怎麼知道這一點?通過日誌文件中的標籤號? – Kini
是的那些聲音我喜歡心跳......你需要做的是從你的對手方得到訂婚的FIX規則,並開始向他們請求不同類型的消息...... – rupweb