Many of you should have been quite familiar with the Disruptor from the LMAX team. I happened to read through and did try out a sample project to see how the RingBuffer can be used with WCF.
The sample code is very simple and straight forward. It illustrates how the RingBuffer can be used to sequence calls from Multiple Producers to a Single Consumer.
The code is self explanatory if you are familiar with Disruptor internals. Here is a very brief summary of the code.
A Consumer WCF Service receives Byte Stream messages from Producers and dumps them into the
MP1CSequencingBuffer is a wrapper class around the
RingBuffer. This class abstracts away the details of setting up the
RingBuffer, the logic of adding an entry to the
RingBuffer and finally getting notified when an new item is available through the
ByteArrayItemProcessor simulates the the Business Logic processing. The incoming byte stream is de-serialized and a simple message counter is maintained to track messages from each Producer.
The Solution has 4 projects. The Disruptor, a Producer (WCF Client Console App) and a Consumner (WCF Service Console App) and a shared project with utility and shared classes.
Make sure to start the Consumer before starting the Producer.
This is my first attempt on understanding and using the Disruptor. So any feedback or improvements would be gladly accepted and greatly appreciated.
The code can be downloaded from here.