zoukankan      html  css  js  c++  java
  • QuickFix MsgHandler

    Your fromApp() callback gets a Message object. That message is actually a NewOrderSingle or ExecutionReport or something. Rather than making you figure it out, QF lets you inherit from MessageCracker. To use it, call crack() in yourfromApp(), as follows:

    void fromApp( const FIX::Message& message, const FIX::SessionID& sessionID )
     throw( FIX::FieldNotFound&, FIX::IncorrectDataFormat&, FIX::IncorrectTagValue&, FIX::UnsupportedMessageType& )
    {
     crack(message, sessionID);
    }
    

    What crack() does is this:

    1. Converts your Message into the proper subclass (e.g. NewOrderSingleExecutionReport, etc)
    2. Calls your user-defined onMessage(subtype) callback, if defined. If not defined, it throws an UnsupportedMessageTypeexception and your app will automatically send a BusinessMessageReject (35=j) to the counterparty.

    So, do you want to handle NewOrderSingle messages? Great, just define an onMessage(NewOrderSingle) callback.

    void onMessage( const FIX42::NewOrderSingle& message, const FIX::SessionID& )
    {
     // Do whatever you want with your NewOrderSingle message's content.
     // Note that this message and the one passed to crack() are the same, content-wise.
    }

    Do you want to handle ExecutionReports? Define onMessage(ExecutionReport). And so on.

    But what about those message types you don't want to handle? It would suck if you had to add handlers to reject all those other message types, but luckily, you don't have to. As I said earlier, if you don't define an onMessage(), QF will reject it for you. (If you want to swallow a particular message type and ignore it without rejection, then just define an onMessage() call with no body.)

    Does that clear it up a bit? Perhaps now http://quickfixengine.org/quickfix/doc/html/receiving_messages.html might read a little easier -- the bottom section talks about the MessageCracker.

    http://www.rqna.net/qna/ihiwzy-questions-about-quickfix-message-cracking.html

  • 相关阅读:
    HeadFirst Ruby 第七章总结 references
    《HTTP 权威指南》笔记:第三章 HTTP 报文
    HTTP 权威指南 第二章 URL 与资源
    HeadFIrst Ruby 第七章总结 hashes
    HeadFIrst Ruby 第六章总结 block return values
    面向对象的面试题
    属性,类方法,静态方法,Python2和3方法
    类的抽象类接口类,多态封装
    类的继承
    面向对象空间和组合
  • 原文地址:https://www.cnblogs.com/xiangshancuizhu/p/2934309.html
Copyright © 2011-2022 走看看