[QFJ-512] How do I change the order of the header tags? Created: 04/Mar/10  Updated: 15/Dec/14  Resolved: 20/Mar/11

Status: Closed
Project: QuickFIX/J
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Other Priority: Default
Reporter: Willis Todd Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Environment:

Using FIX 4.4 (QuickFIX/J) in Eclipse.


Issue Links:
Relates
is related to QFJ-416 Support Header/Trailer field ordering... Open

 Description   

I currently have a working application for one broker using FIX 4.4 and want to use it to connect to another broker using 4.4 with different information in my config file to login, but the problem I am having is that the second broker wants the first seven tags in a specific order, slightly different than my app that is currently sending them and I don't know how to change it. I'm not a professional programmer, so maybe that's why I am feeling so lost, but here is where I am at:

Their spec asks for the first 7 fields in the exact order, tag 8, 9, 35, 49, 56, 34, 52. But I have 8, 9, 35, 34, 49, 50.

8=FIX.4.4
9=139
35=A
34=1
49=senderCompIDme
50=
52=20100217-19:24:46.109
56=THEIRDEMO_QUOTE.FOREX.NET
57=56
553=userName
554=passWord123
98=0
108=30
141=Y
10=107

Seeing that tag 50 is blank, maybe I should delete that one while I'm at it? If anyone has done this, or can explain how, I am totally lost! At this point, they won't even let me login to the second one without the order of these tags being changed.
Any and everyone's help is greatly appreciated!
Thanks in advance!



 Comments   
Comment by Laurent Danesi [ 04/Mar/10 ]

Hi,

You need to modify your FIX44.xml file to set the order you want for each message (8,9,35,49,56,34 et 52 in your case).
After that, you must regenerate the Fix Messages with Ant task (or Eclipse Ant launcher) specifying this property:

<param name="generator.orderedFields" value="true"/>

This will generate FIX Messages with ordered fields and should fix your issue.

Laurent

Comment by Willis Todd [ 04/Mar/10 ]

Hey Laurent,
Thanks for the quick response! This is something I've never done before, so forgive me for sounding ignorant. So here is the first part of my xml file:

<fix major="4" minor="4">
<header>
<field name="BeginString" required="Y"/>
<field name="BodyLength" required="Y"/>
<field name="MsgType" required="Y"/>
<field name="SenderCompID" required="Y"/>
<field name="TargetCompID" required="Y"/>
<field name="OnBehalfOfCompID" required="N"/>
<field name="DeliverToCompID" required="N"/>
<field name="SecureDataLen" required="N"/>
<field name="SecureData" required="N"/>
<field name="MsgSeqNum" required="Y"/>
<field name="SenderSubID" required="N"/>
<field name="SenderLocationID" required="N"/>
<field name="TargetSubID" required="N"/>
<field name="TargetLocationID" required="N"/>
<field name="OnBehalfOfSubID" required="N"/>
<field name="OnBehalfOfLocationID" required="N"/>
<field name="DeliverToSubID" required="N"/>
<field name="DeliverToLocationID" required="N"/>
<field name="PossDupFlag" required="N"/>
<field name="PossResend" required="N"/>
<field name="SendingTime" required="Y"/>
<field name="OrigSendingTime" required="N"/>
<field name="XmlDataLen" required="N"/>
<field name="XmlData" required="N"/>
<field name="MessageEncoding" required="N"/>
<field name="LastMsgSeqNumProcessed" required="N"/>
<group name="NoHops" required="N">
<field name="HopCompID" required="N"/>
<field name="HopSendingTime" required="N"/>
<field name="HopRefID" required="N"/>
</group>
</header>

The required tags are the ones I need, and they are already in the order I need if we ignore the tags not required. So I just want to make sure this is the first part you were talking about. The part about regenerating the Fix messages with Eclipse Ant launcher is the part I have never done and I can't find. And do I just put the line of code you mentioned inside the xml file at the top? Or is that put somewhere else when I find the Ant Launcher? Again, I apologize for being such a newbie on this.
Thanks again for your help!

Comment by Laurent Danesi [ 04/Mar/10 ]

Hi,

Sorry, I will try to be more precise this time .
So, firstly you need to download the source version of quickFixJ (from SVN or in zip format).
Go to the Core folder and edit the build.xml file, you should see this property:

<property name="generator.orderedFields" value="false" />

change it to

<property name="generator.orderedFields" value="true" />

Save the file.

Put your FIX44.xml file in quickfixj/core/src/main/resources.

Finally regenerate the Java code of the FIX messages by opening a CommandLine in quickfixj/core and type:

ant generate.code.

Feel free to contact me if you need more informations.

Laurent

Comment by Willis Todd [ 04/Mar/10 ]

Thank you again Laurent!
So I thought I had what I needed, but I can't find a folder named "Core" or the build.xml anywhere within the quickFixJ folder and sub folders, so I am wondering if I am using the wrong thing. This is the file path on my computer where I am looking:
D:\quickfixj-1.4.0-bin\quickfixj
But in that folder I only see folders bin, doc, etc, lib, src.zip, a license file, and several jar files. I noticed one of them was "quickfixj-core-1.4.0" and tried looking in that, but decided that can't be what you are talking right? I did find some other files on my computer named "build.xml" but none of them had the line of code you mentioned in them and appear to be for non FIX programs anyway.
So does it look like I have downloaded the wrong thing? What I have allows me to run FIX with the one broker just fine, so I would think everything I need should be there, but it sounds now like I need to download something different? I think this is the link to the what I downloaded before and am now looking at, is this what I should be using?
http://sourceforge.net/projects/quickfixj/

Comment by Laurent Danesi [ 05/Mar/10 ]

Hi,

Yes, you are correct you need to download another package http://sourceforge.net/projects/quickfixj/files/QuickFIX_J/1.4.0/quickfixj-1.4.0-src.zip/download containing the source files thsi time instead of jar files.

Laurent

Comment by Willis Todd [ 05/Mar/10 ]

I don't know what I wasn't able to find that, but thank you very much for the link! I have done every step now except for the last one. Here's what I see in the command line when I try to do the last step:

C:\quickfixj>cd \quickfixj\core

C:\quickfixj\core>ant generate.code.
'ant' is not recognized as an internal or external command,
operable program or batch file.

C:\quickfixj\core>ant generate.code
'ant' is not recognized as an internal or external command,
operable program or batch file.

C:\quickfixj\core>

Is this because I need to install something more for me to use ant? In your first message you mentioned something about Eclipse Ant launcher, so I'm wondering if I should try that maybe? Or maybe if I did something wrong i the command line, you can tell me that.
Thanks again so much for your help, I was so lost before for like two weeks!!

Comment by Willis Todd [ 05/Mar/10 ]

I was trying to use Eclipse to do this and made a new project, then in the java settings, under the source tab, I clicked on Link Additional Source, and selected the quickfixj folder. Then I used the package explorer to right click the build.xml in the core folder and selected Run As ---> 2 Ant Build... and the Edit Configuration window comes up with jar [default] "build jar files" being the only thing selected, and I click run. But I don't see where the jar files being created, or where they are being sent to if they are created. So I don't know if that was what I was supposed to do or not. Let me what you think.
Thanks again!

Comment by Willis Todd [ 08/Mar/10 ]

So I thought maybe ant wasn't installed, so I have been working on installing it and used winant from this site:
http://code.google.com/p/winant/
And used the following link to download Java JDK 6 update 18:
http://java.sun.com/javase/downloads/widget/jdk_javafx.jsp
It still didn't quite work, but after a restart of the computer, this seems to have done the trick, as it says "BUILD SUCCESSFUL" at the end. However, I do not see any .jar files to replace the other ones I was using. So do I not need new jar files?
Thanks again! And I hope the links above will help others that have the problem I was having with ant, though probably most people coming here already know that.

Comment by Laurent Danesi [ 09/Mar/10 ]

Hi,

Great job, now you have the new source files respecting the ordered fields you provided in FIX44.xml.

You must now execute the ant task release.versioned that will generate all the jars you need. This task is in the build.xml at the root of your quickfixj project.

Laurent

Comment by Willis Todd [ 09/Mar/10 ]

Thanks again Laurent!! I did as you said above, and it did generate .jar files, though I'm not sure if it did everything it was supposed to, as I saw this at the end:

test.unit.junit:
[junit] Running quickfix.ApiCompatibilityTest
[junit] Tests run: 1715, Failures: 1, Errors: 0, Time elapsed: 32.797 sec

BUILD FAILED
C:\quickfixj-1.4.0-src\quickfixj\build.xml:130: The following error occurred whi
le executing this line:
C:\quickfixj-1.4.0-src\quickfixj\build.xml:44: The following error occurred whil
e executing this line:
C:\quickfixj-1.4.0-src\quickfixj\build.xml:27: The following error occurred whil
e executing this line:
C:\quickfixj-1.4.0-src\quickfixj\core\build.xml:175: The following error occurre
d while executing this line:
C:\quickfixj-1.4.0-src\quickfixj\core\build.xml:235: Test quickfix.ApiCompatibil
ityTest failed

Total time: 4 minutes 8 seconds
C:\quickfixj-1.4.0-src\quickfixj>

So I tried using the jar files anyway in place of the jar files I was using, but I get errors initiating sessionSettings and it never sends the fix message. I finally got it to send the fix message after including these 3 previously used jar files: mina-core-1.1.2.jar, slf4j-api-1.5.3.jar, slf4j-jdk14-1.5.3.jar, and just excluding this 1 previously used jar: quickfixj-all-1.4.0.jar. However, the fix message tags that get sent are still in the order they were before, rather than in the new order specified in the beginning of the FIX44.xml file. Is this something to do with the 3 other jar files I am using do you think? I was hoping I wouldn't need to include any of the old jar files, but then like I said, it doesn't send any fix message at all for me. What do you suggest I do?
If it's of any help, this is the print out I get when I try to run the application with only the nex jar files just generated:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at quickfix.SessionSettings.<init>(SessionSettings.java:64)
at quickfix.SessionSettings.<init>(SessionSettings.java:118)
at FIXTradingTester2.main(FIXTradingTester2.java:733)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more

Thanks again for all your help Laurent!
-Willis

Comment by Willis Todd [ 17/Mar/10 ]

Hey Laurent,
I talked to someone else who is more familiar with fix in c++ and less familiar with quickfixj, but they told me to do the same thing as you had and I still got the same result as above. Then he even tried to do it himself and got the same result I did with the build failed message. Like when I did it though, it did still produce jar files, though the jar files still were sending the header tags in the wrong order. I am really lost here, is there anything else that you can suggest I try?

Comment by Willis Todd [ 30/Mar/10 ]

Thanks again for your help Laurent! To anyone else having this problem, I had my jars rebuilt with a header.cfg file that specifies what order to put the tags in. If anyone else is in the same boat as I was and needs it, just let me know and I can send it to you!

Comment by Willis Todd [ 21/Jun/11 ]

Hey Aadil, I can't remember for sure if I already helped you with this or not, but in case I didn't, please feel free to e-mail me and I can share the code and rebuilt jars that worked for me. willis11of12 at rome dot com

Comment by Jörg Thönnes [ 21/Jun/11 ]

As I created QFJ-416, I was sure that the header order cannot specified. Did this change meanwhile?

Otherwise, I could pick up some tweaks out of my code...

Comment by Willis Todd [ 24/Jun/11 ]

Jörg, I can send you the jar files that were created for me that have a header order config file with them, though I recently realized that with using the newest version of quickfix/j, I don't have any problem connecting to the same platform without using it. So now I am wondering if they really did much. It seems that using it allows me to change the order of some tags, but not all of them... weird. Anyway, just send me an e-mail if you want me to send you what I have and you can check it out.

Comment by Andreea Ion [ 12/Apr/12 ]

Hy, I tried to do exactly like you but I didn't manage to succed. I am building the project in eclipse and I have the same error as you
BUILD FAILED
C:\quickfixj\core\build.xml:81: The following error occurred while executing this line:
C:\quickfixj\core\build.xml:89: The following error occurred while executing this line:
C:\quickfixj\core\build.xml:109: Error running javac.exe compiler

Can you tell me how can I do thsi work, in order to change the hearder tads .
Thank you,
Andreea

Comment by Øyvind Hansen [ 11/Dec/14 ]

Hello,

we are having the same issue with FIX 4.4. We have set up a specific order of fields in the header in the datadictionary. However, in the fix messages the header fields are sorted by fix tag number, conflicting the order in the datadictionary. Because this post is over four years old, we were wondering if this solution is still the one to go for. Our broker also wants the fields in the header in a specific order.

Thank you,
Øyvind

Comment by Christoph John [ 15/Dec/14 ]

AFAIK there currently is no other way than to rebuild QFJ as Laurent suggested in his first comment.

Generated at Tue May 07 07:52:03 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.