Re: [Quickfix-developers] Session.SendToTarget issue
Brought to you by:
orenmnero
|
From: Oren M. <or...@qu...> - 2006-02-22 17:29:39
|
QuickFIX makes no assumptions about what session you want to send your
message on. If there is only one session, it doesn't decide to send to
that session even if its the only one. It wants you to be explicit about
what session you intend to send to.
--oren
Mike Smith wrote:
> Alexander,
>
> Thanks for your quick response. I got it to work, but I’m still a bit
> confused.
>
> I tried sendToTarget(message, senderCompID, targetCompID) and that
> didn’t work.
>
> I then tried sendToTarget(message, senderCompID, targetCompID,
> qualifier) and that worked.
>
> I’ve only got one session active, so I would think that
> sendToTarget(message) would work fine.
>
> Also, the qualifier value that I put as the 4^th parameter of
> sendToTarget listed above is the same qualifier value I put when
> calling sendToTarget(message, qualifier), which didn’t work.
>
> Again, it is working now, and I greatly appreciate your help.
>
> Thanks,
>
> Mike
>
> ------------------------------------------------------------------------
>
> *From:* Alexander Gorbachev [mailto:ago...@ac...]
> *Sent:* Wednesday, February 22, 2006 11:03 AM
> *To:* Mike Smith; qui...@li...
> *Subject:* Re: [Quickfix-developers] Session.SendToTarget issue
>
> Hello,
>
> My guess is that you chose the wrong sendToTarget() method signature.
> In your method "GLOBEX" is a session qualifier. If "GLOBEX" is a
> targetCompId, than you need to use the sendToTarget(message,
> senderCompID, targetCompID).
>
> Best regards,
>
> Alexander
>
> ----- Original Message -----
>
> *From:* Mike Smith <mailto:MS...@rj...>
>
> *To:* qui...@li...
> <mailto:qui...@li...>
>
> *Sent:* Wednesday, February 22, 2006 5:44 PM
>
> *Subject:* [Quickfix-developers] Session.SendToTarget issue
>
> I’m just starting out with QuickFix, so I’m sure this is a very
> beginner level question.
>
> I’m coding in c# 2.0 and have setup my solution very much like the
> example executor solution. The only thing is, is that I’m
> instantiating a ThreadedSocketInitiator instead of an Acceptor,
> because I want to send out new orders, cancels, etc. I’m logging
> in fine and heartbeating, but when I build a new order message and
> try to send it, I get the following error.
>
> [QuickFix.SessionNotFound] = {"Exception of type
> 'QuickFix.SessionNotFound' was thrown."}
>
> From looking at the examples, I can’t see why I’m getting this
> error. I’ve verified that the SessionIdentifier is correct and I
> am heartbeating, so I know the session is active.
>
> Below is my code in Application.cs
>
> public class Application: MessageCracker, QuickFix.Application
>
> {
>
> public void onLogon(SessionID sessionID) { }
>
> public void onLogout(SessionID sessionID) { }
>
> public void toApp(Message message, SessionID sessionID) { }
>
> public void fromAdmin(Message message, SessionID sessionID) { }
>
> public void fromApp(Message message, SessionID sessionID) { }
>
> public void toAdmin(Message message, SessionID sessionID)
>
> {
>
> message.setField(new SenderSubID("060"));
>
> message.setField(new SenderLocationID("060"));
>
> message.setField(new TargetSubID("G"));
>
> message.setField(new RawData("HGY"));
>
> message.setField(new RawDataLength(3));
>
> }
>
> public void onCreate(SessionID sessionID) { }
>
> public void SendMessage(Message message)
>
> {
>
> Session.sendToTarget(message, "GLOBEX");
>
> }
>
> }
>
> SendMessage is called from an event handler in the main class.
>
> Here is the main class.
>
> class Program
>
> {
>
> #region "PRIVATE FIELDS"
>
> private Application application = new QuickFixConsole.Application();
>
> #endregion
>
> #region "ENTRYPOINT"
>
> static void Main(string[] args)
>
> {
>
> try
>
> {
>
> Program program = new Program();
>
> SessionSettings settings = new
> SessionSettings("C:\\Source\\backup\\API.NET\\Session.config");
>
> Application application = new QuickFixConsole.Application();
>
> MSSQLStoreFactory storeFactory = new MSSQLStoreFactory(settings);
>
> MessageFactory messageFactory = new DefaultMessageFactory();
>
> ScreenLogFactory logFactory = new ScreenLogFactory(true,true,true);
>
> ThreadedSocketInitiator initiator = new
> ThreadedSocketInitiator(application, storeFactory, settings,
> logFactory, messageFactory);
>
> initiator.start();
>
> Globex globex = new Globex("c:\\Orders", "*.FIX", new
> MessageHandler(program.Program_OnMessage));
>
> globex.StartProcessor();
>
> Console.WriteLine("press <enter> to quit");
>
> Console.Read();
>
> initiator.stop();
>
> }
>
> catch (Exception ex)
>
> {
>
> Console.WriteLine(ex.Message);
>
> }
>
> }
>
> #endregion
>
> #region EVENT HANDLERS
>
> private void Program_OnMessage(Message message)
>
> {
>
> try
>
> {
>
> application.SendMessage(message);
>
> //Session.sendToTarget(message, "GLOBEX");
>
> }
>
> catch (Exception ex)
>
> {
>
> throw ex;
>
> }
>
> }
>
> #endregion
>
> Any and all help is greatly appreciated.
>
> Thanks,
>
> Mike
>
|