How to set sequence numbers manually in QuickFixJ?

偶尔善良 提交于 2019-12-11 17:23:51

问题


I'm acting as an acceptor. Is there a way to set sequence numbers manually?

The first idea I had, was to modify .seqnums files, but it does not work.

Google mentions existence of setNextSenderMsgSeqNum and setNextTargetMsgSeqNum methods, however I can't tell on which object I should call them (using quickfixj 1.4).

I'm aware that setting sequence numbers by hand is discouraged and there are bunch of flags like ResetOnLogon and ResetOnDisconnect, but I have no control over initiator and there are bunch of other acceptors (test-tools) which are using the same session.

Application myApp = new FIXSender();
settings = new SessionSettings(sessionConfig);
MessageFactory messageFactory = new MessageFactory();
MessageStoreFactory storeFactory = new FileStoreFactory(settings);
LogFactory logFactory = new FileLogFactory(settings);
Acceptor acceptor = new SocketAcceptor(myApp, storeFactory, settings, logFactory, messageFactory);
acceptor.start();

回答1:


First of all you need to explore the quickfixJ code to see how it is done.

Secondly what is the reason to use such an old version of quickfixJ ? Why not upgrade to the most recent version.

Thirdly you should be very wary of changing sequence numbers if you don't understand properly how they are used in the communication. If you don't understand you are guaranteed to get into murky problems.

You can do something like

Session.lookupSession(sessionID).setNextSenderMsgSeqNum())

But before you do it, it is very important to understand how sequence numbers are used




回答2:


You can set the FIX fields, override the toAdmin callback

@Override
public void toAdmin(Message message, SessionID sessionId) {
      message.setBoolean(ResetSeqNumFlag.FIELD, true);
}


来源:https://stackoverflow.com/questions/49878316/how-to-set-sequence-numbers-manually-in-quickfixj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!