简体   繁体   中英

Is there a way to replay quickFIX/J messages

Is there a way to replay messages from the quickFIX/J in the *messages.log file?

It appears this question was asked a while back, but I'm wodering of any new developments: Store And Replay WCF Messages

The intent is to be able to re-run messages even when the other side of the FIX connection is not available.

While I could not repeat FIX messages in my setup I was able to "repeat" them using unit tests and using my own simple acceptor with examples from the QuickFIX/J manual .

I have created a simple acceptor with the "FooApplication" to receive messages and answer/mock some QuoteRequests

public static void main(String[] args)  throws Exception {
    // FooApplication is your class that implements the Application interface
    FooApplication application = new FooApplication();

    SessionSettings settings = new SessionSettings(new FileInputStream(fileName));
    MessageStoreFactory storeFactory = new FileStoreFactory(settings);

    LogFactory[] logFactories = new LogFactory[] {new FileLogFactory(settings)};
    LogFactory logFactory = new CompositeLogFactory(logFactories);

    MessageFactory messageFactory = new DefaultMessageFactory();
    Acceptor acceptor = new SocketAcceptor(application, storeFactory, settings, logFactory, messageFactory);
    acceptor.start();

}

Then using unit tests I initiate a FooInitiator and call for example the sendLogout() from the FooClient

public class FooClient extends quickfix.fix42.MessageCracker implements quickfix.Application {

    // sendQuoteRequest

    // sendNewOrderSingle

    private boolean sendMessage(Message message) {
    boolean result = false;
    try {
        result = Session.sendToTarget(message, session);
    } catch (SessionNotFound e) {
        logger.error("FooApplication SessionNotFound", e);
        result = false;
    }
    return result;
    }

    public boolean sendLogout() {
        return sendMessage(new Logout());
    }
}

If you are looking at FIX messages logs perhaps you might want to check in case you don't know HermesJMS its free and open source.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM