Dashboard > QuickFIX/J > ... > Articles > Implementing Custom Logons
QuickFIX/J Log In | Sign Up   View a printable version of the current page.
Implementing Custom Logons
Added by Steve Bate, last edited by Jörg Thönnes on Mar 28, 2008  (view change)
Labels: 
(None)

If you need to add fields to the logon message when you initiate a session, do it in the toAdmin callback of the Applicationinterface. For example, a counterparty may ask to have a user identifier placed in the SenderSubID field and a password put into the RawData field.

In the toAdmin callback, if the message is a logon message (being sent to the counterparty) then add your fields. The sent message will include whatever changes you make to the Logon message in the callback.

private String userID;
private String password;

public void toAdmin(Message message, SessionID sessionId) {
    if (isMessageOfType(message, MsgType.LOGON)) {
        addLogonField(message);
    }
    super.toAdmin(message, sessionId);
}

private void addLogonField(Message message) {
    message.getHeader().setField(new SenderSubID(userID));
    message.getHeader().setField(new RawDataLength(password.length()));
    message.getHeader().setField(new RawData(password));
}

private boolean isMessageOfType(Message message, String type) {
    try {
        return type.equals(message.getHeader().getField(new MsgType()).getValue());
    } catch (FieldNotFound e) {
        logErrorToSessionLog(message, e);
        return false;
    }
}

private void logErrorToSessionLog(Message message, FieldNotFound e) {
    LogUtil.logThrowable(MessageUtils.getSessionID(message), e.getMessage(), e);
}

Is QF/J able to accept custom Logon messages created above? Say, how can it be configured to accept a logon with SenderSubID or TargetSubID?

Posted by Henry Chan at Sep 03, 2008 10:22 | Permalink
Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.1.5a Build:#411 Mar 16, 2006) - Bug/feature request - Contact Administrators

SourceForge.net Logo