3

有没有办法在 *messages.log 文件中重播来自 quickFIX/J 的消息?

看来这个问题是不久前被问到的,但我正在考虑任何新的发展: Store And Replay WCF Messages

目的是即使在 FIX 连接的另一端不可用时也能够重新运行消息。

4

1 回答 1

0

虽然我无法在我的设置中重复 FIX 消息,但我能够使用单元测试并使用我自己的简单接受器和QuickFIX/J 手册中的示例来“重复”它们。

我创建了一个带有“FooApplication”的简单接受器来接收消息并回答/模拟一些 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();

}

然后使用单元测试我启动一个 FooInitiator 并从 FooClient 调用例如 sendLogout()

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

如果您正在查看 FIX 消息日志,也许您可​​能想要检查一下,以防您不知道HermesJMS它是免费和开源的。

于 2012-11-07T22:59:51.820 回答