Create and Send FIX Message

In QWFIX, FIX messages have to created by a FIXSession. The created message contains all kinds of information, from message schema to associated session (and session persistence).

Application can add fields to the message once it is created. Because message knows its schema, any invalid operation will trigger an excpetion (e.g. unknown tag ID, invalod field data type, restricted fields such as SenderCompID or TargetCompID, etc).

FIX messages are sent through a FIXSession. It has to be sent through the same session that created it; otherwise an exception will be thrown. Once the FIXMessage is sent, a "FIX message token" will be returned. The token is a 8 bytes long integer in QWF)X_J. Application should keep the token and use it to retrieve the message it has sent in the future. NEVER KEEP THE REFERENCE OF THE MESSSAGE. USE TOKEN INSTEAD!

    // Variable "msgType" is a string value of FIX message type.
    // Note: FIX 5.0+ supports multiple versions of FIX schemas per session, use
    // FIXSession.createMessage(String, int) to create message using schema index.
    FIXMessage message = session.createMessage(msgType);
    // Add contents to the message by calling FIXMessageComponent.setValue.
    long token = session.sendMessage(message, true);
    // The returned message token can be save and used to retrieve the message later on.
    // Never cache the created message. It should be discarded. 
    // Always use the token to retrieve whenever the message needs to be referenced.