FIXAntennaJava
2.26.0
|
A prepared message can be created in three different ways:
To create a FIX prepared message please use the FIXSession.prepareMessage() and FIXSession.prepareMessageFromString() methods. Thereafter you can set/change the desired field values of a message and send it to the counter-party many times.
For example:
To parse a string containing a raw FIX message into the FIXPreparedMessage class, use the FIXSession.prepareMessageFromString(byte[] message, String type, MessageStructure structure) method.
For example:
To create prepared message from FIXFieldList object please use FIXSession.prepareMessage(FIXFieldList message, String type, MessageStructure structure) method
To add a field to message use the MessageStructure.reserve(int tagId, int length) method. Also you can give a hit to builder about field type with similar methods methods MessageStructure.reserveString(int tagId, int length) and MessageStructure.reserveLong(int tagId, int length). In the last case builder will be able to prepare more optimized structure for a new message. Keep in mind, all tags in message will be in order in which you have reserved it. Length is strictly fixed. If length of the tag is undetermined, you can use MessageStructure.VARIABLE_LENGTH constant as a length parameter in reserve(int,int) method. In such case length will be auto adjusted. But keep in mind such way is much more slower then fixed size for field. You will get a best perfomance if you prepared message will have only fixed length fields.
If you reserved 5 bytes, content length of this tag should be equal to 5 bytes too. Otherwise engine will mark the length for such field as undetermined (MessageStructure.VARIABLE_LENGTH) automatically. But there is an exception from this rule: if you try to set a numeric value (int, long, double) with a lover length, engine will automatically fill the tag value with leading "0" to the required length.
Fixed tag value length:
Variable tag value length:
To change a field value use FIXFieldList.set() method:
In case of repeating groups you can use such way to set concrete tag value:
Entries in repeating group have a numbers starting from 1.