I would like to customize the sent Login message in the toAdmin method by adding the Username and Password values from the current session settings. Something like that:
@Override
public void toAdmin(Message message, SessionID sessionId) {
Header header = message.getHeader();
if (!header.isSetField(MsgType.FIELD) || !header.getString(MsgType.FIELD).equals(MsgType.LOGON))
{
// not a logon message: do not modify it
return;
}
Session session = Session.lookupSession(sessionId);
message.setField(new Username(seesion.getSettingValue("Username")));
message.setField(new Password(seesion.getSettingValue("Password")));
}
The getSettingValue
method doesn't exist. Is there any way to do this in quickfixJ? BTW this is possible in quickfixn.
I assume you mean that you want to define custom Username/Password settings in your config file. (QF does not have these built-in.)
This link will show you how to use custom settings. http://www.quickfixj.org/confluence/display/qfj/Using+Custom+Settings
(Ignore the bit in the prose about
getSessionSettings()
; this method does not appear to actually exist in the current build.)In case that page goes down, in a nutshell the process is this:
Somehow give your MessageCracker app a reference to your
SessionSettings
object (whether by constructor or get/set or however).In your
toAdmin()
, do something like this:(I haven't compiled this code; please let me know if I have a syntax error and I'll fix it.)
I literally just added the C# equivalent to the QF/n User FAQ yesterday. You must be on the QF/n mail list, or else just have really great timing.
(I should probably add this to the QF/j User FAQ as well.)