I created a custom object in FIX44.xml .I want to call onMessage handler in receiver for same custom object using crack implementation but adding crack in fromApp of reciever does not call onMessage .Here is the code

@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 Answers

0
TT. On

Hello isha and welcome to Stack Overflow! I'm suspecting you are not having your class implement the MessageCracker interface (you did not include the whole class definition).

The correct use of this interface, and how to define the methods to crack your messages is described in the QuickFIX/J Receiving Messages documentation.

To quote the relevant parts, which includes an example:

Define your application like this:

import quickfix.Application;
import quickfix.MessageCracker;

public class MyApplication
  extends MessageCracker implements quickfix.Application

QuickFIX/J version 1.16 or newer supports a new version of MessageCracker that dynamically discovers message handling method using either a method naming convention (similar to earlier versions of QuickFIX/J) or by tagging handlers methods with the @Handler annotation.

Examples...

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
    }
}