轻量化的 p2p 组件

Kevin Lovato 03824cf7db Update package location for build cache 10 سال پیش
build b8dfa5c05b Fix nuspecs dependency to match packages.config 10 سال پیش
lib 945f8f5ff7 Use NuGet for StructureMap, and update to v3.1.4.143 11 سال پیش
src 628f159f20 Add "ManualOnly" category to all ignored tests 10 سال پیش
tools c619bc2eba Add nuget.exe in tools 11 سال پیش
.gitignore b367e726ee Log a warning when we drop peer updates for non-existent peers 10 سال پیش
ClickToBuild.bat 0158214736 Reverted the build changes made for AppVeyor since they were not needed 11 سال پیش
ClickToPackage.bat a72b2128a0 Update clicktopublish 11 سال پیش
ClickToPublish.bat a72b2128a0 Update clicktopublish 11 سال پیش
LICENSE.md 1a0c9882f4 Update copyrights dates to 2015 - Bonne année ! 10 سال پیش
README.md a22a52f87f Update readme 10 سال پیش
RELEASE_NOTES.md 965d9d6d07 Update release notes up to 1.2.4 10 سال پیش
appveyor.yml 03824cf7db Update package location for build cache 10 سال پیش

README.md

#About

Zebus is a lightweight peer to peer service bus, built with CQRS principles in mind. It allows applications to communicate with each other in a fast and easy manner. Most of the complexity is hidden in the library and you can focus on writing code that matters to you, not debugging messaging code.

Introduction

Zebus is peer to peer, so it does not depend on a broker to dispatch messages between the peers. This allows it to reach a throughput of 140k msg/s and a roundtrip latency under 500µs (have a look at the Performance page for details).

It is resilient thanks to the absence of a broker and an optional persistence feature that ensures that messages are not lost if a peer is down or disconnected.

It is stable, since we have been using it on a production environment at Abc Arbitrage for more than two years. Although we did not release all the necessary bricks yet so you will have to wait a few minor versions to have a fully resilient prodable product.

Key concepts

Peer

We call a peer any program that is connected to the bus, a peer is identified by a unique identifier called a PeerId that looks like this: MyAmazingPeer.0 (we use this convention to identify different instances of the same service).

Event

An event is sent by a peer to notify everyone who is interested that something happened (ex: MyBusinessObjectWasSaved, AlertTriggered...).

Command

A command is sent to a peer asking for an action to be performed (ex: SaveMyBusinessObjectCommand).

Message Handler

A class deriving from IMessageHandler<T> will be scanned by the bus and will be used to handle messages of the T kind on reception.

Bus

The piece of code that is the point of entry to use Zebus, the methods that you will use the most are Publish(IEvent) and Send(ICommand).

A quick demo

On startup, the bus will scan your assemblies for message handlers and notify the other peers that you are interested by those messages. When a peer publishes a message, it will use the Directory to know who handles it and send the message directly to the correct recipients.

Receiver

public class MyHandler : IMessageHandler<MyEvent>
{
    public void Handle(MyEvent myEvent)
    {
        Console.WriteLine(myEvent.Value);
    }
}

Sender

public void MethodThatSends(IBus bus)
{
    bus.Publish(new MyEvent { Value = 42 });
}

Event description

[ProtoContract]
public class MyEvent : IEvent
{
    [ProtoMember(1)]
    public int Value { get; set; }
}

And you're set ! This is all the code you need to send an event from one machine to the other. If you want to read more about how the magic happens, have a look at the wiki. Or if you want a more detailed walkthrough (what to reference, how to start the Bus...) visit the Quick start page.

Release notes

We try to stick to the semantic versioning principles and keep the release notes up to date.

Copyright

Copyright © 2015 Abc Arbitrage Asset Management

License

Zebus is licensed under MIT, refer to LICENSE.md for more information.