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

  • 相关阅读:
    SSM框架的基本配置
    Python开发的飞机打外星人小游戏
    python中count和index
    破解Xmind时长
    光流法简介
    Linux常用命令
    GitHub常用命令
    极大似然估计与最大后验概率估计
    在linux上加速git clone
    Endnote导入共享数据
  • 原文地址:https://www.cnblogs.com/xiangshancuizhu/p/2934309.html
Copyright © 2011-2022 走看看