Search code examples
quickfixj

Enhance the login message in QuickFIX/J


Maybe it's a newbie question, but is there a way to "enhance" the login message with particular tags that the acceptor side requires (such as tags 95 and 96 with specific values)?

As a reference, I'm just following this article and I am getting this logon error:

<20231025-13:17:59, FIX.4.2:MySrcCompID->MyTgtCompID, event> (MINA session created: local=/{source-ip}:53706, class org.apache.mina.transport.socket.nio.NioSocketSession, remote=/{target-ip}:9000)
<20231025-13:18:00, FIX.4.2:MySrcCompID->MyTgtCompID, outgoing> (8=FIX.4.29=7535=A34=149=MySrcCompID52=20231025-13:18:00.37156=MyTgtCompID98=0108=3010=249)
<20231025-13:18:00, FIX.4.2:MySrcCompID->MyTgtCompID, event> (Initiated logon request)
<20231025-13:18:00, FIX.4.2:MySrcCompID->MyTgtCompID, event> (Disconnecting: Encountered END_OF_STREAM)

Solution

  • To add fields to the Login message, you can use the toAdmin callaback in your quickfix.Application class. Here is an example to add username/password fields:

    public void toAdmin(quickfix.Message message, SessionID sessionID)
    {
        final String msgType = msg.getHeader().getString(MsgType.FIELD);
        if(MsgType.LOGON.compareTo(msgType) == 0)
        {
            msg.setString(quickfix.fields.Username.FIELD, _username);
            msg.setString(quickfix.fields.Password.FIELD, _password);
        }
    }