当我尝试使用配置文件的URL调用SessionSettings的构造函数时,它只加载文件中存在的最后一个会话。
我已尝试打印我的代码从配置文件中读取的内容,但我得到了这个:
[DEFAULT]
StartTime=00:00:00
EndTime=23:59:59
ReconnectInterval=5
TargetCompID=Server
SenderCompID=Client
DataDictionary=C:\config\FIX42.xml
HeartBtInt=30
FileStorePath=C:\logsBadisInitiatorStore
UseDataDictionary=Y
FileLogPath=C:\logsBadisInitiator
[SESSION]
StartTime=00:00:00
ConnectionType=acceptor
EndTime=23:59:59
BeginString=FIX.4.2
SocketAcceptPort=9878
TargetCompID=server1
SessionName=badisAcc289
SenderCompID=client1
SocketAcceptAddress=localhost
UseDataDictionary=N
但我的配置文件包含的内容不止于此:
[default]
FileStorePath=data
SenderCompID=Client
TargetCompID=Server
FileLogPath=C:\logsBadisInitiator
StartTime=00:00:00
EndTime=23:59:59
HeartBtInt=30
ReconnectInterval=5
UseDataDictionary=Y
DataDictionary=C:\config\FIX42.xml
FileStorePath=C:\logsBadisInitiatorStore
[session]
SessionName=badisAcc2
BeginString=FIX.4.2
SenderCompID=client1
TargetCompID=server1
ConnectionType=acceptor
SocketAcceptPort=9878
SocketAcceptAddress=localhost
StartTime=00:00:00
EndTime=23:59:59
UseDataDictionary=N
[session]
SessionName=test211
BeginString=FIX.4.2
SenderCompID=client1
TargetCompID=server1
ConnectionType=initiator
SocketConnectPort=9878
SocketConnectHost=localhost
StartTime=00:00:00
EndTime=23:59:59
UseDataDictionary=N
[session]
SessionName=badisAcc3
BeginString=FIX.4.2
SenderCompID=client1
TargetCompID=server1
ConnectionType=acceptor
SocketAcceptPort=9878
SocketAcceptAddress=localhost
StartTime=00:00:00
EndTime=23:59:59
UseDataDictionary=N
[session]
SessionName=badisAcc4
BeginString=FIX.4.2
SenderCompID=client1
TargetCompID=server1
ConnectionType=acceptor
SocketAcceptPort=9878
SocketAcceptAddress=localhost
StartTime=00:00:00
EndTime=23:59:59
UseDataDictionary=N
[session]
SessionName=badisAcc289
BeginString=FIX.4.2
SenderCompID=client1
TargetCompID=server1
ConnectionType=acceptor
SocketAcceptPort=9878
SocketAcceptAddress=localhost
StartTime=00:00:00
EndTime=23:59:59
UseDataDictionary=N
这是我编写的用于加载sessionSettings的代码:
String URLConfigFile="c:/config/initiatorSettings.txt";
sessionSettings = new SessionSettings(URLConfigFile);
System.out.println("sessionSettings tostring "+sessionSettings.toString());
如何解决此问题?
答案 0 :(得分:5)
根本原因 一个会话的配置会破坏另一个会话,因为两个会话都具有相同的SessionID。
两个会话都具有相同的SessionID,它是从BeginString / SenderCompID / TargetCompID(有时是其他字段)构建的。
SessionSetting实际上是每个会话的单个词典的哈希值,由SessionID键入。由于您的会话具有相同的SessionID,因此它们相互冲突。
您的配置也存在逻辑问题
如果您希望这两个会话相互通信,那么发件人/目标值应相反,例如
[session]
SessionName=badisAcc2
BeginString=FIX.4.2
SenderCompID=server1
TargetCompID=client1
ConnectionType=acceptor
...
[session]
SessionName=test211
BeginString=FIX.4.2
SenderCompID=client1
TargetCompID=server1
ConnectionType=initiator
...