How to set sequence numbers manually in QuickFixJ?

2019-08-16 16:58发布

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();

2条回答
【Aperson】
2楼-- · 2019-08-16 17:20

You can set the FIX fields, override the toAdmin callback

@Override
public void toAdmin(Message message, SessionID sessionId) {
      message.setBoolean(ResetSeqNumFlag.FIELD, true);
}
查看更多
放我归山
3楼-- · 2019-08-16 17:26

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

查看更多
登录 后发表回答