I am working on designing trade system using Java Realtime ( Sun JRTS 2.2 ) and would like to few questions about best practices, because I am afraid of inventing the wheel and pretty sure that my task was already solved.
So I have thread that continuously reading the socket, parsing bytes and extracting messages (binary protocol ). Afterwards, I should send messages to the algorithm, that actually does some calculation and make decision to trade or not.
So I think the way I should design this system is to split it into 2 parts. Producer ( periodic(?) Realtime thread that extracts bytes from socket, parse it ) and Consumer ( Realtime thread (periodic/sporadic?) that extracts messages from producer, manipulates with them etc ).
So the first question is how to design high performance communication between these 2 threads ( producer/consumer )? Also I would love to hear the comments about the existing experience in designing such systems, advices and etc.
Thank you for your help!
I am working with a similar problem but in a different domain:
Here is how I dealt with that: