我正在使用quickfixj(1.6.4)库。我可以看到所有消息都非常正确地隔离(传入/传出/事件)
<20180504-07:32:14, FIX.4.2:CLIENT2/SUB-> , event> (Session FIX.4.2:CLIENT2/SUB-> schedule is daily, 00:00:00-UTC - 00:00:00-UTC) <20180504-07:32:14, FIX.4.2:CLIENT2/SUB-> , event> (Created session: FIX.4.2:CLIENT2/SUB-> ) <20180504-07:32:15, FIX.4.2:CLIENT2/SUB-> , event> (Configured socket addresses for session: [/x.x.x.x:xxxx]) <20180504-07:32:15, FIX.4.2:CLIENT2/SUB-> , event> (MINA session created: local=/y.y.y.y:yyyy, class org.apache.mina.transport.socket.nio.NioSocketSession, remote=/x.x.x.x:xxxx) <20180504-07:32:16, FIX.4.2:CLIENT2/SUB-> , outgoing> (8=FIX.4.29=7935=A34=149=CLIENT252=20180504-07:32:16.386) <20180504-07:32:16, FIX.4.2:CLIENT2/SUB-> , event> (Initiated logon request) <20180504-07:32:16, FIX.4.2:CLIENT2/SUB-> , incoming> (8=FIX.4.29=8035=A34=1) <20180504-07:32:16, FIX.4.2:CLIENT2/SUB-> , event> (Logon contains ResetSeqNumFlag=Y, resetting sequence numbers to 1) <20180504-07:32:16, FIX.4.2:CLIENT2/SUB-> , event> (Received logon)
然而,我无法找到在我的代码中按原样获取这些隔离消息的方法。
PS:我深入挖掘,并达到ScreenLogFactory.java,最终似乎记录了我在控制台日志中看到的内容。但是找不到在我的代码中提取传入/传出消息的方法。EDIT1: 如何捕获会话级消息?
提前致谢。
答案 0 :(得分:1)
要启动SocketInitiator,您必须向其传递quickfix.Application
的实例。在您的实现中,您可以在toAdmin
和fromAdmin
实现中查看心跳。
class YourFixApplication implements Application {
@Override
public void fromAdmin( Message message, SessionID sessionID ) {
MsgType msgType;
try {
msgType = (MsgType) message.getHeader( ).getField( new MsgType( ) );
}
catch( FieldNotFound e ) {
e.printStackTrace();
return;
}
if( msgType.valueEquals( MsgType.HEARTBEAT ) ) {
System.out.println( ">>> Heartbeat <<<" );
}
}
// same deal with toAdmin implementation
// ...
}
答案 1 :(得分:0)
TT。的答案是正确的,尽管我需要更改一些语义以使其对我有用:
public void ToAdmin(Message message, SessionID sessionID)
{
msgType = (MsgType).message.Header.GetField(new MsgType());
catch(FieldNotFoundException e)
{
//error message
return;
}
if(msgType.Obj.Equals(MsgType.HEARTBEAT))
{
// print out wherever or do whatever with the heartbeat msg
}
}