轻量化的 p2p 组件

Mendel Monteiro-Beckerman bab0993faf Core: instead of only trying to replay messages when a persistence peer starts, try on every send пре 5 година
build e81e031ad6 Remove AppVeyor пре 6 година
lib 1721621c16 Rename Linux native binary пре 6 година
src bab0993faf Core: instead of only trying to replay messages when a persistence peer starts, try on every send пре 5 година
.editorconfig 636928c134 Add .editorconfig пре 7 година
.gitattributes 3d9ebce80b Normalize line endings пре 10 година
.gitignore 123cbb5dd7 v3.5.0 пре 6 година
LICENSE.md b571dab224 Update Copyright notice пре 9 година
README.md 585f641fbd Tweak badges пре 6 година
RELEASE_NOTES.md 8953d1af89 Update release notes пре 6 година
RELEASE_NOTES_DIRECTORY.md 375e4122d8 Directory: update version number and release notes пре 7 година
Zebus.DotSettings 8ec3d2f40d Add Resharper common settings file пре 9 година
azure-pipelines.yml ea6bdee023 Remove --no-build in pack пре 6 година
build.bat df46688e90 Remove remaining AppVeyor references пре 6 година
execute-tests.bat df46688e90 Remove remaining AppVeyor references пре 6 година

README.md

Zebus

Build Status NuGet Gitter

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 six years, handling hundreds of millions of messages per day.

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.

Requirements

On Windows, you will need to have Microsoft Visual C++ 2017 Redistributable installed in order to load the x86 or the x64 version of libzmq embedded in the project.

Release notes

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

Other repositories

  • Zebus.MessageDsl - a DSL which simplifies the writing of ProtoBuf contracts for Zebus
  • Zebus.TinyHost - a lightweight host used to run Zebus enabled services
  • Zebus.Samples - miscellaneous samples that show how to get started with Zebus

Copyright

Copyright © 2019 Abc Arbitrage Asset Management

License

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

Tools

We use

resharper_icon