quickfix

How to Ensure All Asynchronous Messages Sent with QuickFIX C++ Library are Acknowledged by Acceptor?


I'm using the QuickFIX C++ library to send a stream of messages asynchronously using the sendToTarget method. However, I'm facing challenges in determining if all messages have been received and acknowledged by the acceptor before stopping the initiator.

Since the sendToTarget method is asynchronous and the acceptor does not reply to my messages, I'm unsure about the status of message acknowledgment. This uncertainty makes it difficult to know when it's safe to stop the initiator.

Below is a simplified version of my code:

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

Solution

  • FIX is an optimistic protocol so there are no explicit ACKs.

    I'd suggest to send a TestRequest with a specific TestReqID message after you have sent all your messages.

    When you receive the Heartbeat with your TestReqID you can assume that all former messages have been received.