{{Quickfixn}} Reconnecting problem

Ondra Květ kwitee at gmail.com
Tue Jul 17 07:07:58 PDT 2012


Hi everyone,
I have found another problem relating to this. I am simply asking the
provider for market data and saving them to database. I implemented Grant's
solution in following way:

*// this method is running in the working thread, which is saving the data
to DB*
*void WorkerMethod() *
*{*
*  while (true) // infinite loop is checking the queque and sending the top
pair to DB*
*  {*
*    if (!CurrencyPairQueue.IsEmpty())*
*    {*
*      ServiceDatabase.SaveToDB(CurrencyPairQueue.GetTopPair());*
*      System.Threading.Thread.Sleep(25); // sleep the thread for 25ms for
lower CPU load*
*    }*
*  }*
*}*

The queque is saving the data as it goes from the OnMessage event in main
thread, if some currency pair come more then once, the older data is
dropped.

The issue in my solution is high CPU load (cca 15% in average with 25ms
sleep) of my service. I thought of several possibilities to fix this:

1) Get rid of the infinite loop. I thought about this, but I did not find a
better way how to do it since the queque is almost never empty (any
event-like solution will be very similar to this in my opinion).
2) Save whole queque in one insert statement. The problem is that the pairs
are saving to database through storage procedure (it also process the
data), so the entire process would have to be rewriten. And I am not
entirely convinced it would help.

I also tried to play with the Thread.Sleep value - the higher values is
forcing too much values to drop out from the queque.

What solution do you think will be the best? Or maybe I am all wrong and
you can find another one.

Regards,
kwitee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quickfixn.com/pipermail/quickfixn-quickfixn.com/attachments/20120717/c385a74f/attachment.htm>


More information about the Quickfixn mailing list