MaLoad
MaLoad

Reputation: 3

QuickFix MessageCracker: How to decide which messages should be implemented?

I am working on implementing Initiator side for a broker FIX platform using QuickFix in C++. Their FIX spec provides the list of messages they support; Logon, Heartbeat and other messages.

MessageCracker (Fix 4.2) provides two overloads for same type. For example

virtual void onMessage( ResendRequest&, const FIX::SessionID& ) {}

and

virtual void onMessage( const ResendRequest&, const FIX::SessionID& ) {}

Edit: I have a class that is derived from Application and MessageCracker and it calls crack(FIX::Message&) from within toAdmin() that results in calling onMessage() (the version without const).

My confusion was related to the point that which version of onMessage() I should be overriding? The one with const FIX::Message& or the other?

Upvotes: 0

Views: 1724

Answers (2)

Grant Birchmeier
Grant Birchmeier

Reputation: 18504

I understand that first one is for sending and second one is for receiving.

That's totally wrong. Neither are for sending.

To be honest, I'm not sure why both exist, but I'd use the const version, as DumbCoder suggests. There's not really any good reason to modify the received message.

And another note, because your intentions are not clear in your question:
Don't implement OnMessage for admin messages (e.g. Login, Heartbeat, etc.). If you need to react to those (and you probably don't), use the FromAdmin() callback.

Upvotes: 2

DumbCoder
DumbCoder

Reputation: 5766

virtual void onMessage( const ResendRequest&, const FIX::SessionID& )

The crack passes the const reference, so the above function will be invoked. Moreover you shouldn't be changing the received FIX message, unless you have very specific needs. onMessage is for receiving messages, not sending.

Upvotes: 3

Related Questions