Creating and Sending FIX Messages
For each message type defined in the XML schema (e.g., NewOrderSingle), the Chronicle FIX CodeGenerator creates a corresponding interface. It is recommended to use these interfaces whenever possible. For each interface, the CodeGenerator generates two implementations:
DefaultXXX (e.g., DefaultNewOrderSingle): These are Data Transfer Objects (DTOs) or Plain Old Java Objects (POJOs) that support a straightforward programming model. Fields have standard getters and setters, and there is a toString() method available. See Creating Messages as DTOs for more details.
MessageGenerator: This implementation is more concise and performance-optimized, but does not support getters. Setters are non-idempotent, meaning each message field should be set only once. Once a field is set, it cannot be read or changed, as data is streamed directly to a buffer rather than stored in a DTO. If a setter is called twice for the same field, the value is written to the buffer twice. The order in which fields are set determines the order they are written to the buffer. This method is ideal for scenarios where the order of fields matters and is the highest performing way to send messages. See Creating Messages Using MessageGenerator for more information.
Writing data directly to a buffer is more efficient than writing to a DTO, as it avoids making an intermediate copy. However, because data is streamed directly, if any field in a message changes, the entire message must be rewritten. Thus, messages created this way are write-only.
The table below summarises the key differences between MessageGenerator and DTO messages:
MessageGenerator | DTO |
|
|