Warm tip: This article is reproduced from serverfault.com, please click

Compare two FixMessages in QuickFIXJ

发布于 2011-03-22 10:39:58

I need to compare two fix messages (say two ExecutionReports) in QuickFIXJ.

Let's call them er1 and er2

Now, what I mean by comparing them is that a bunch of fields must be identical. for instance I care that tag 55, tag 207, tag 1 are the same. but not others.

It seems to me that the only way to do so is to write something as expensive (performance-wise) as this:

public static boolean compare(ExecutionReport er1,ExecutionReport er2) 
{
   StringField sf1 = new StringField(55);
   StringField sf2 = new StringField(55);

   er.getField(sf1);
   er.getField(sf2);

   if (sf1.getValue().equals(sf2.getValue())==false) return false;

   ... // continue with all of the other fields
   ... // in the same way

}

Am I missing something ? can somebody suggest a better/faster approach ?

Questioner
chacko
Viewed
0
35k 2017-11-27 20:49:58

There is no function to compare two fix messages in the API, it seems. But instead of comparing the whole message fields, the best would be to compare only those fields which are mandatory. An extension would be if you are dead sure those fields would be present in the FIX message.

Another option would be to compare in a thread different than the one for the session where you are sending and receiving messages. It would be hard to decide if the messages need to be compared in the same thread, without knowing what happens downstream with the Execution reports or what are your actions if the Execution reports match.