如何确保所有使用 QuickFIX C++ 库发送的异步消息都被 Acceptor 确认?

问题描述 投票:0回答:1

我正在使用 QuickFIX C++ 库通过

sendToTarget
方法异步发送消息流。然而,我面临着在停止发起者之前确定接受者是否已收到并确认所有消息的挑战。

由于

sendToTarget
方法是异步的,并且接受者没有回复我的消息,所以我不确定消息确认的状态。这种不确定性使得很难知道何时可以安全地停止发起者。

下面是我的代码的简化版本:

// Code snippet to send messages using QuickFIX C++ library

#include <quickfix/Application.h>
#include <quickfix/Session.h>

class MyApplication : public FIX::Application {
public:
    void sendMessages() {
        // Loop to send multiple messages
        for (int i = 0; i < numMessages; ++i) {
            // Construct and send message
            FIX::Message message;
            // Populate message fields
            // ...

            // Send message asynchronously
            FIX::Session::sendToTarget(message);
        }
    }

    // Override other necessary methods of FIX::Application class
};

int main() {
    Application app(...);
    SocketInitiator.start();
    app.sendMessages();
    SocketInitiator.stop();
}
quickfix
1个回答
0
投票

我建议您在发送完所有消息后发送包含特定

TestRequest
消息的
TestReqID

当您收到

Heartbeat
TestReqID
时,您可以假设之前的所有消息均已收到。

© www.soinside.com 2019 - 2024. All rights reserved.