Question

I am in the process of QuickFix service initiator implementation in c# which needs to do the following.

  1. Listen to incoming QuoteRequest messages and save them to a local database/queue.
  2. Our users will have the ability to hit the Bids on these quote requests. These selections will be saved in a local queue. Service will need to read the queue and send Quote messages back to the sender.
  3. Listen to QuoteResponse / BusinessReject and QuoteStatus Messages from the sender and store on our end.

I'm planning to have two threads in my service.

Thread 1: This will be used to listen to incoming QuoteRequest, Quote response, Businessreject and quotestatus messages. Outgoing ExecutionReport will be sent from OnMessage event handler while cracking QuoteResponse message. Those messages will get stored in our system and published on our sites/queue etc.

Thread 2: This will listen to another local queue and sends out Quote(bids) messages to the acceptor. Quotes will be sent out using Session.SendToTarget.

Is there a way to configure two instances of initiators to be used in each thread ? Or do I create one initiator and add two sessions. Would it work if both initiators are using same socket server and port ? Also if a message is not cracked by one thread would it be available for the other thread ? I couldnt find any example of a multithreaded approach to handle both incoming and outgoing messages.

Appreciate any inputs/recommendation on a correct approach to implementation.

Was it helpful?

Solution

This is only one connection, and only one session, so there should only be one Initiator.

You can set up different worker threads, but your various OnMessage() callbacks should be a common entry point. They can dispatch their received messages to your thread (you could have them push received messages into a queue or something for your threads to consume). Your threads can do what they need to do and then call sendToTarget as appropriate.

Above all else, try not to put any expensive logic in the QF callbacks; put it in the threads. Other than that, you can do what you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top