- Notifications
You must be signed in to change notification settings - Fork15
Effortlessly send messages anywhere on the network using Reactive Extensions (RX). Transport protocol is ZeroMQ.
License
NetMQ/NetMQ.ReactiveExtensions
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Effortlessly send messages anywhere on the network using Reactive Extensions (RX). Uses NetMQ as the transport layer.
Fast! Runs at >120,000 messages per second on localhost (by comparison, Tibco runs at 100,000 on the same machine).
The API is a drop-in replacement forSubject<T>
from Reactive Extensions (RX).
As a refresher, to useSubject<T>
in Reactive Extensions (RX):
varsubject=newSubject<int>();subject.Subscribe(message=>{// If we get an error "Cannot convert lambda ... not a delegate type", install Reactive Extensions from NuGet.Console.Write(message);// Prints "42".});subject.OnNext(42);
The new API starts with a drop-in replacement forSubject<T>
:
varsubject=newSubjectNetMQ<int>("tcp://127.0.0.1:56001");subject.Subscribe(message=>{Console.Write(message);// Prints "42".});subject.OnNext(42);// Sends 42.
This is great for a demo, but is not recommended for any real life application.
For those of us familiar with Reactive Extensions (RX),Subject<T>
is a combination of a publisher and a subscriber. If we are running a real-life application, we should separate out the publisher and the subscriber, because this means we can create the connection earlier which makes the transport setup more deterministic:
varpublisher=newPublisherNetMq<int>("tcp://127.0.0.1:56001");varsubscriber=newSubscriberNetMq<int>("tcp://127.0.0.1:56001");subscriber.Subscribe(message=>{Console.Write(message);// Prints "42".});publisher.OnNext(42);// Sends 42.
If we want to run in separate applications:
// Application 1 (subscriber)varsubscriber1=newSubscriberNetMq<int>("tcp://127.0.0.1:56001");subscriber1.Subscribe(message=>{Console.Write(message);// Prints "42".});// Application 2 (subscriber)varsubscriber2=newSubscriberNetMq<int>("tcp://127.0.0.1:56001");subscriber2.Subscribe(message=>{Console.Write(message);// Prints "42".});// Application 3 (publisher)varpublisher=newPublisherNetMq<int>("tcp://127.0.0.1:56001");publisher.OnNext(42);// Sends 42.
Currently, serialization is performed usingProtoBuf. It will handle simple types such asint
without annotation, but if we want to send more complex classes, we have to annotate like this:
// For Protobuf support, include NuGet package protobuf-net from Marc Gravell.[ProtoContract]publicstructMyMessage{[ProtoMember(1)]publicintNum{get;set;}[ProtoMember(2)]publicstringName{get;set;}}varpublisher=newPublisherNetMq<MyMessage>("tcp://127.0.0.1:56001");varsubscriber=newSubscriberNetMq<MyMessage>("tcp://127.0.0.1:56001");subscriber.Subscribe(message=>{Console.Write(message.Num);// Prints "42".Console.Write(message.Name);// Prints "Bill".});publisher.OnNext(newMyMessage(42,"Bill");
The NuGet package 0.9.3 is designed for .NET 4. It depends on Reactive Extensions v2.2.5 (this is difficult to find, can download the packages manually from NuGet).
The NuGet package 0.9.4-rc7 is designed .NET Core 1.1, .NET 4.5, and .NET Standard 1.6. If you want to build it for other platforms, please let me know. If you have trouble loading this, load the Git branch for the 0.9.3 release.
As of v0.9.4-rc7, this package will build for:
- .NET 4.5 and up
- .NET Core 1.1
- .NET Standard 1.6 and up
As this library supports .NET Standard 1.6 (which is a subset of .NET Core 1.1), this library should be compatible with:
- Windows
- Linux
- Mac
This library is tested on Window and Linux. If it passes it's unit tests on any given platform, then it should perform nicely on different architectures such as Mac.
- InstallVisual Studio 2015 Update 3.
- Install ".NET Core 1.1 SDK - Installer" fromhttps://www.microsoft.com/net/download/core.
- NuGet Restore. It may not compile until a manual "nuget restore" is performed for each project (this also rebuilds the
project.lock.json
file). You can either do this from the command line, or by right clicking on the solution and choosingRestore NuGet packages
. - If the project does not compile on your machine, raise an issue here on GitHub.
NOTE: Not compatible with .NET Core 1.0 or .NET Core 1.0.1. Must install .NET Core 1.1 and above to avoid potential compile errors.
To check out the demos, see:
- Publisher: Project
NetMQ.ReactiveExtensions.SamplePublisher
- Subscriber: Project
NetMQ.ReactiveExtensions.SampleSubscriber
- Sample unit tests: Project
NetMQ.ReactiveExtensions.Tests
- Runs at >120,000 messages per second on localhost.
- Compatible with all existing Reactive Extensions code, as it implements IObservable and IObserver from Microsoft.
- Can use
.Where()
,.Select()
,.Buffer()
,.Throttle()
, etc. - Supports
.OnNext()
,.OnException()
, and.OnCompleted()
. - Properly passes exceptions across the wire.
- Supported by a full suite of unit tests.
- SeeObvs, an fantastic RX wrapper which supports many transport layers including NetMQ, RabbitMQ and Azure, and many serialization methods including ProtoBuf and MsgPack.
- SeeObvs.NetMQ, the RX wrapper with NetMQ as the transport layer.
- Search forall packages on NuGet that depend on RX, and pick out the ones that are related to message buses.
- Check out Kafka. It provides many-to-many messaging, with persistance, and multi-node redundancy. And its blindingly fast.
See theWiki with more documentation.
About
Effortlessly send messages anywhere on the network using Reactive Extensions (RX). Transport protocol is ZeroMQ.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.