QuickFIX/J User Manual

Customizing Message Code Generation

QuickFIX/J includes message libraries generated from standard FIX meta data. However, there are several ways to customize code generation in QuickFIX/J.

The simplest customization is to just modify one or more data dictionaries (e.g., FIX44.xml) and rebuild QFJ. This allows you to add custom fields, define new messages not included in the specification, change whether fields are required or optional, and so on.

You can also do more advanced customization by using the quickfix.codegen.MessageCodeGenerator class. You can define code generation tasks (quickfix.codegen.MessageCodeGenerator.Task) that customize various aspects of the generation process. The types of customizations currently supported include:

Property Description
specification path to the XML file containing the FIX meta data (e.g. /my/dir/CUSTOM_FIX.xml)
transformDirectory path to the XSLT transforms used to generate the message-related source code. Usually this will reference the standard QFJ XSLT templates in quickfix/codegen. However, you can modify the templates and put the modified templates wherever you want.
outputBaseDirectory The base directory where generated source code will be placed.
overwrite Controls whether existings files are overwritten. Usually this would be true.
messagePackage The Java package for the generated messages. This would be something like "my.message.fix42". In QFJ, for example, the package for the FIX 4.2 generated messages is "quickfix.fix42".
fieldPackage The Java package for the generated field. This would be something like "my.message.fix42.fields". In QFJ, the fields are generated in the package "quickfix.fields" for all versions (newer versions overwrite older versions). By changing this property, you could generate fields into separate packages for each specification version.
orderedFields Generates message classes where regular (nongroup) body fields are ordered as specified in the meta. Although the FIX specification does not require this ordering, some exchanges do require it. There may be a slight (probably very slight) performance degradation when using this option.
decimalGenerated Generates BigDecimals for price, quantity, and similar fields. The default code generation generated doubles to be compatible with the QuickFIX C++ implementation.

To generate you own message library, you can create a program that uses the MessageCodeGenerator to process the Task you have defined. Then use a simple Ant script to do the code generation, compile the classes, and create a message JAR file. Depending on the type of customization you've done, you may need to write a MessageFactory implementation, include that in the JAR file, and then reference the factory in the session configuration. For Ant script examples, see the QFJ core build scripts.

The most advanced customization is to modify the XSLT templates used to generate the message source code. If you are interested in this level of customization, please look at the XSLT template source code for more information.