Tuesday, October 9, 2012

ZeroMQ + MsgPack + .NET

I have created a simple testbed to demonstrate 2 .NET applications communicating with each other using ZeroMQ Publisher/Subscriber connections for the communications layer, and MsgPack as the serialization/deserialization layer.

ZeroMQ is a highly efficient and scalable network layer that acts as a reliable messaging layer on top of raw sockets. Performance is key here.

For ZeroMQ I use the x86 NuGet package available here: http://nuget.org/packages/clrzmq/2.2.5

MsgPack is a serialization library where efficient storage of the serialized data, and performance of the serialization and deserialization is the main focus.

For MsgPack I found that the current NuGet package was somewhat behind the times, so I built the dll by downloading the latest source from https://github.com/msgpack/msgpack-cli and building it in release configuration, and adding it as a reference to both the client and server applications.

With the two libraries combined, an application should be very efficient and performance should be very high. I built this testbed primarily to see how straightforward it was to use these libraries from .NET applications. As you can see, it is very straightforward indeed!

Here is the client implementation:

Here is the server implementation:

Here is the shared model:

The full solution is available here: https://github.com/SneakyBrian/ZeroMQ_MessagePack_Testbed

1 comment: