quickFixj中自定义对象的破解实现

时间:2019-03-13 13:40:35

标签: quickfixj

我在FIX44.xml中创建了一个自定义对象。我想使用破解实现为同一自定义对象在接收器中调用onMessage处理程序,但在收件人的fromApp中添加破解不会调用onMessage。这是代码

@Override
    public void fromApp(Message arg0, SessionID arg1) throws FieldNotFound, IncorrectDataFormat, 
    IncorrectTagValue, UnsupportedMessageType {
     crack(arg0, arg1); // should calls onMessage(..,..) of custom object
    }


 public void onMessage(MyCustomObject message, SessionID sessionID)
            throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {
        //do something
    }

1 个答案:

答案 0 :(得分:0)

您好isha,欢迎来到Stack Overflow!我怀疑您没有让类实现MessageCracker接口(您没有包括整个类定义)。

QuickFIX/J Receiving Messages文档中介绍了此接口的正确用法以及如何定义破解消息的方法。

引用相关部分,其中包括一个示例:

  

这样定义您的应用程序:

import quickfix.Application;
import quickfix.MessageCracker;

public class MyApplication
  extends MessageCracker implements quickfix.Application
     

QuickFIX / J 1.16或更高版本支持新版本的   动态发现消息处理方法的MessageCracker   使用方法命名约定(类似于早期版本)   或通过使用@Handler标记处理程序方法   注释。

     

示例...

import quickfix.Application;
import quickfix.MessageCracker;

public class MyApplication extends MessageCracker implements quickfix.Application
{
    public void fromApp(Message message, SessionID sessionID)
            throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {
        crack(message, sessionID);
    }

    // Using annotation
    @Handler
    public void myEmailHandler(quickfix.fix50.Email email, SessionID sessionID) {
        // handler implementation
    }

    // By convention (notice different version of FIX. It's an error to have two handlers for the same message)
    // Convention is "onMessage" method with message object as first argument and SessionID as second argument
    public void onMessage(quickfix.fix44.Email email, SessionID sessionID) {
        // handler implementation
    }
}