Thursday 29 January 2009

Fix message manipulation

I have had a chance to work on some projects which involved minor modifications to fix messages on a repetative basis. Since this project was in C++ i wrote an initial header file to get the required result. later on out of curiosity i ported the same methods to java and bingo i have methods to work both in C++ and Java. The discussion which proceeds is related to methods and their usage and source code for the same.

Need:
The work involved parsing of FixSession.log files and making some generic changes to it (like replacing all client names and codes with cypher text or changing stock codes to dummp code and so on). This was done to take care of compliance and regulatory requirements. So, i worte two methods :
String getValueForTag(String fixMsg,String tag)

String replaceTagValue(String fixMsg, String tag, String replace)

Why all string manipulation? the reason was i was reading a file containing these messages and so string was the most logical choice.. only later did i realise that this is what makes the task easier when working with realtime systems. Time for some code now.... (pasting images as formatting gets lost on blogger mail me for full source code)

replaceTagValue[java]


replaceTagValue[C++]


getValueForTag[java]


getValueForTag [C++]


After you are done with FixMessage manipulation you need to recalculate the checksum value and the body length value before u send out this message on the network. (why is this done? well these checks are useful in determining if the message recieved is complete in all respects and if not a resend can be requested. This is vital in case of applications working in unreliable network connectivity) And to do this you can use the following methods:

For CheckSum Calculation C++ (Tag 10)



Java:


For BodyLength calculation (tag 9) C++:


Java:



No comments: