0

I have created a application to send messages between client-server and I am having a problem on server side.

I want to write the incoming NewOrderSingle message( .body extension file) files in store folder on server side.

The newordersingle message along with executionreport message get written into store file on client side. but on server side I don’t get application messages(file with .body extension) in store file.

How to write the incoming application messages to the file and not the admin messages.

My sample code is as follows:

    public class clsFIXServer : QuickFix.MessageCracker, QuickFix.IApplication

    {
        public void FromApp(QuickFix.Message message, QuickFix.SessionID sessionID)

        {
            Console.WriteLine("IN:  " + message);

            Crack(message, sessionID);
        }

         public void OnCreate(QuickFix.SessionID sessionID)

        {
        }

        public void OnLogon(QuickFix.SessionID sessionID)
        {  
        }
        public void OnLogout(QuickFix.SessionID sessionID)
        { 
        }
        public void ToAdmin(QuickFix.Message message, QuickFix.SessionID sessionID)
        {  
        }
        public void ToApp(QuickFix.Message message, QuickFix.SessionID sessionId)
        {
            Console.WriteLine("OUT: " + message);
        }

     public void OnMessage(QuickFix.FIX44.NewOrderSingle n, SessionID s)
    {
        Symbol symbol = n.Symbol;
        Side side = n.Side;
        OrdType ordType = n.OrdType;
        OrderQty orderQty = n.OrderQty;
        Price price = new Price(DEFAULT_MARKET_PRICE);
        ClOrdID clOrdID = n.ClOrdID;

        switch (ordType.getValue())
        {
            case OrdType.LIMIT:
                price = n.Price;
                if (price.Obj == 0)
                    throw new IncorrectTagValue(price.Tag);
                break;
            case OrdType.MARKET: break;
            default: throw new IncorrectTagValue(ordType.Tag);
        }

        QuickFix.FIX44.ExecutionReport exReport = new QuickFix.FIX44.ExecutionReport(
            new OrderID(GenOrderID()),
            new ExecID(GenExecID()),
            new ExecType(ExecType.FILL),
            new OrdStatus(OrdStatus.FILLED),
            symbol, //shouldn't be here?
            side,
            new LeavesQty(0),
            new CumQty(orderQty.getValue()),
            new AvgPx(price.getValue()));

        exReport.Set(clOrdID);
        exReport.Set(symbol);
        exReport.Set(orderQty);
        exReport.Set(new LastQty(orderQty.getValue()));
        exReport.Set(new LastPx(price.getValue()));

        if (n.IsSetAccount())
            exReport.SetField(n.Account);

        try
        {
            Session.SendToTarget(exReport, s);
        }
        catch (SessionNotFound ex)
        {
            Console.WriteLine("==session not found exception!==");
            Console.WriteLine(ex.ToString());
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
}

My client side function that creates the newordersingle message :-

 public void Run()

 {
    objEMSOrder = ((FIXFormatter.EMSOrder)messageQueue.Receive().Body);

        if (this._session.SessionID.BeginString == "FIX.4.4")

         {

    QuickFix.FIX44.NewOrderSingle m = objMessageCreator.NewOrderSingle44MessageCreator(objEMSOrder); 
         **//DLL FUNCTION THAT CREATES MESSAGE**      


         if (m != null)
             {
                m.Header.GetField(Tags.BeginString);
                SendMessage(m);
             }

          }

   }
  • Have you looked at the example apps? No offense, but this code is kind of crazy. It seems that you may not not know what you're doing. Where is your `OnMessage(NewOrderSingle)` function? Is your client *not* a QF app? Are you even able to establish a heartbeat between client and server? – Grant Birchmeier Jan 31 '14 at 14:50
  • hello grant,sorry I did the mistake while putting the code above.I have edited the code now.We can establish connection between server and client.Now please check the code and give your reply.We are referring Quickfix/n sample code. – – Vishwesh R. Feb 03 '14 at 10:10
  • Do you see "IN: " messages on your console? – Grant Birchmeier Feb 03 '14 at 15:33
  • yes Grant,we can see IN and OUT messages on our console.The client side store files folder contains the IN and OUT messages i.e. in '.body' files. We can't write the messages to server side store files folder.The files get created. '.Body' files don't contain the data on server side. – Vishwesh R. Feb 04 '14 at 11:41
  • I'm kind of confused. As a programmer, you should not be messing with the `store` directory. This is internal state stuff used by the engine. I really think you're focusing on something that is not actually important. – Grant Birchmeier Feb 04 '14 at 16:51
  • Thanks grant.you always have been helpful. – Vishwesh R. Feb 07 '14 at 06:28

1 Answers1

2

The message store is for internal use by the FIX session protocol. It only stores outgoing messages so that if there is a sequence gap is can resend previously sent messages. You want to look at the FileLogFactory and FileLog classes. Those will log both incoming and outgoing messages.

Frank Smith
  • 978
  • 5
  • 11