我手动在配置文件中指定了主机和端口。我尝试的只是动态更改该文件中的值或是否有其他替代选项根据用户选择更改主机和端口名称
[DEFAULT]# Settings which apply to all the Sessions.
ConnectionType=initiator
LogonTimeout=30
ReconnectInterval=30
ResetOnLogon=Y
FileLogPath=E:\eclipse_kepler\Workspace\FIX_Analyzer\src\simulator\logs.txt
[SESSION]# Settings specifically for one session
BeginString=FIX.4.2
SenderCompID=THIS VALUE IS THE CLIENT ID
TargetCompID=THIS VALUE IS THE FIX SERVER ID
SocketConnectHost=192.168.15.58
SocketLocalHost=192.168.15.58
StartDay=sunday
EndDay=friday
StartTime=00:00:00
EndTime=00:00:00
HeartBtInt=30
CheckLatency=N
MaxLatency=240
SocketConnectPort=5005
SocketConnectHost=192.168.15.58
UseDataDictionary=Y
DataDictionary=E:\eclipse_kepler\Workspace\FIX_Analyzer\src\simulator\CustomFix.xml
FileStorePath=C:\Work\QuickFIXJ\sessioninfo
答案 0 :(得分:2)
在quickfix
包中,类SessionSettings
有一个构造函数来加载配置文件。
然后你应该能够使用set方法修改你想要的东西。
例如,要仅为特定会话更改主机:
final SessionSettings ss = new SessionSettings( "session.cfg" );
for( final Iterator<SessionID> i = ss.sectionIterator(); i.hasNext(); ) {
final SessionID id = i.next();
if( id.getSenderCompID().startsWith("quote") )
ss.setString( id, "SocketConnectHost", "123.101.202.010" );
}