Using Disruptor-net With WCF – Part 1

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.

To get started I picked up 1.0 .Net version of the project from here. Although the 2.7 port is available, I thought let me get familiar with 1.0, so I can better appreciate the 2.7 improvements.

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. 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 IBatchHandler. 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.

Advertisements

2 thoughts on “Using Disruptor-net With WCF – Part 1

  1. Pingback: Using Disruptor-net With WCF – 2 « KrishnanSrinivasan's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s