Greetings,
In my trade server application, for every action (user-generated and
ExecutionReport generated) I persist this data in a SQL Server database.
For speed issues, as events occur, I add them to a producer/consumer queue,
which another thread then takes and writes to the underlying database. I'm
attempting to figure out a way to prevent the following scenario from
occurring:
1) trader requests a new order
2) server sends order request to exchange
3) server adds "new order" entry to the queue to be written to the database
4) SERVER CRASH
In other words, I've sent a message to the exchange and haven't logged it
(I've put it on the queue to be logged, but because I don't want to have to
wait for a SQL Server transaction to occur before sending the order to the
exchange, this is all done on a separate thread).
So when I reconnect, the exchange responds with an execution report (confirm
NewOrderSingle) for an order that I do not know existed.
So then I began wondering how QuickFix logs messages sent to the exchange.
Do you
1) send to exchange
2) write to the message store
or vice versa? I would imagine you do it in the order above, otherwise you
would be subject to the speed of writing it to file or database.
Just curious how QuickFix does this, and if anyone has any advice for me and
my problem, I'm all ears.
Much appreciated.
Rick
|