Giorgi Gviani
Giorgi Gviani

Reputation: 28364

How to set sequence numbers manually in QuickFixJ?

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

Upvotes: 1

Views: 4053

Answers (2)

Hemant Singh
Hemant Singh

Reputation: 1598

You can set the FIX fields, override the toAdmin callback

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

Upvotes: 2

DumbCoder
DumbCoder

Reputation: 5766

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

Upvotes: 3

Related Questions