All Projects → daniellittledev → Enexure.microbus

daniellittledev / Enexure.microbus

Licence: mit
MicroBus is a simple in process Mediator for .NET

Projects that are alternatives of or similar to Enexure.microbus

cash-flow
Application for managing cash flows written in ASP.NET Core 6 and Angular 13 (EF Core, Apollo, GraphQL, CQRS)
Stars: ✭ 27 (-86.29%)
Mutual labels:  cqrs, dotnetcore
Mediator.net
A simple mediator for .Net for sending command, publishing event and request response with pipelines supported
Stars: ✭ 237 (+20.3%)
Mutual labels:  dotnetcore, cqrs
Learning.EventStore
A framework for CQRS, Eventsourcing, and messaging that uses Redis pub/sub for messaging and offers event persistence in Redis, SQL Server, or PostgreSQL.
Stars: ✭ 58 (-70.56%)
Mutual labels:  cqrs, dotnetcore
Modular Monolith With Ddd
Full Modular Monolith application with Domain-Driven Design approach.
Stars: ✭ 6,210 (+3052.28%)
Mutual labels:  dotnetcore, cqrs
Weapsy
ASP.NET Core CMS
Stars: ✭ 748 (+279.7%)
Mutual labels:  dotnetcore, cqrs
Quiz
Example real time quiz application with .NET Core, React, DDD, Event Sourcing, Docker and built-in infrastructure for CI/CD with k8s, jenkins and helm
Stars: ✭ 100 (-49.24%)
Mutual labels:  dotnetcore, cqrs
Event Sourcing Castanha
An Event Sourcing service template with DDD, TDD and SOLID. It has High Cohesion and Loose Coupling, it's a good start for your next Microservice application.
Stars: ✭ 68 (-65.48%)
Mutual labels:  dotnetcore, cqrs
Eventflow.example
DDD+CQRS+Event-sourcing examples using EventFlow following CQRS-ES architecture. It is configured with RabbitMQ, MongoDB(Snapshot store), PostgreSQL(Read store), EventStore(GES). It's targeted to .Net Core 2.2 and include docker compose file.
Stars: ✭ 131 (-33.5%)
Mutual labels:  dotnetcore, cqrs
Angular 7 Project With Asp.net Core Apis
Angular 7 Project with ASP.NET CORE APIS | Angular Project
Stars: ✭ 174 (-11.68%)
Mutual labels:  dotnetcore
Dalsoft.restclient
The C# REST Client - the only REST/ HTTP Client you will ever need
Stars: ✭ 185 (-6.09%)
Mutual labels:  dotnetcore
Aspnet Core 3 Registration Login Api
ASP.NET Core 3.1 API for User Management, Authentication and Registration
Stars: ✭ 173 (-12.18%)
Mutual labels:  dotnetcore
Kreta
Modern project management solution
Stars: ✭ 177 (-10.15%)
Mutual labels:  cqrs
Lambdaparser
Runtime parser for string expressions (formulas, method calls). Builds dynamic LINQ expression tree and compiles it to lambda delegate.
Stars: ✭ 187 (-5.08%)
Mutual labels:  dotnetcore
Rocksdb Sharp
.net bindings for the rocksdb by facebook
Stars: ✭ 173 (-12.18%)
Mutual labels:  dotnetcore
Anclafs
ASP.NET Core Library and Framework Support
Stars: ✭ 192 (-2.54%)
Mutual labels:  dotnetcore
Ddd Laravel Sample
A Laravel DDD sample application using CQRS and persisting entities serialized without ORM
Stars: ✭ 172 (-12.69%)
Mutual labels:  cqrs
Json Ld.net
A JSON-LD processor for .NET.
Stars: ✭ 171 (-13.2%)
Mutual labels:  dotnetcore
Netprints
Visual programming for .NET inspired by Unreal Engine's Blueprints
Stars: ✭ 194 (-1.52%)
Mutual labels:  dotnetcore
Liiklus
Reactive (RSocket/gRPC) Gateway for the event-based systems
Stars: ✭ 192 (-2.54%)
Mutual labels:  cqrs
Rafty
Implementation of RAFT consensus in .NET core
Stars: ✭ 182 (-7.61%)
Mutual labels:  dotnetcore

Enexure.MicroBus

Build status

MicroBus is a simple in process mediator for .NET

PM> Install-Package Enexure.MicroBus.Autofac

I wanted a super simple mediator with great support for global handlers. With MicroBus message handlers and global handlers are first class citizens making it easy to get started.

Registering a set of handlers takes a few just lines of code and is fairly terse.

    var busBuilder = new BusBuilder()
        
        // Global Handlers run in order so these are explicitly registered
        .RegisterGlobalHandler<LoggingHandler>()
        .RegisterGlobalHandler<SecurityHandler>()
        .RegisterGlobalHandler<ValidationHandler>()
        .RegisterGlobalHandler<TransactionHandler>()
        
        // Scan an assembly to find all the handlers
        .RegisterHandlers(assembly);

Once your registrations are sorted out then it's just a matter of adding MicroBus to your DI container. Here is now we register MicroBus to Autofac.

    autofacContainerBuilder.RegisterMicroBus(busBuilder);

MicroBus has two main interfaces, the bus and the mediator. A bus will work with the message types, commands, events and queries(request/response). This imposes a strong set of rules around what a message can do. For example you can only have at most one handler for a query or command.

    given(IMicroBus bus)
    
    bus.SendAsync(new TestCommand());  // ICommand
    bus.QueryAsync(new TestQuery());   // IQuery<Query, Result>
    bus.PublishAsync(new TestEvent()); // IEvent

The other is the mediator which is more general. Messages can be anything and don't need to implement any specific interface. This can be useful when interfacing with existing message contracts.

     given(IMicroMediator mediator)
     
     mediator.SendAsync(anyObject);
     mediator.QueryAsync(anyObject);
     mediator.PublishAsync(anyObject);

Commands are the typical entry point for an application. A command is something that you ask the system to do. For example, create a new page the the name of a command is always in the imperative tense. Commands are also interesting in that they don't return anything. In our create a page example you would say create the page "home" or create an object that I can refer to with this Guid instead of create a page and return the Id. The great part about this is you already know what the Id of the resource is going to be.

    class TestCommand : ICommand { }
    
    class TestCommandHandler : ICommandHandler<TestCommand>
    {
        public async Task Handle(TestCommand command)
        {
            Console.WriteLine("Test command handler");
        }
    }

One of the most important things an application needs is a way to deal with cross cutting concerns. In MicroBus this is where global handlers come in. They provide a great way to do work before messages get to the handlers. They also use the nested Russian Doll style approach so each handler will internally call the next handler or handler in the chain.

    public class CrossCuttingHandler : IDelegatingHandler
    {
        public async Task<object> Handle(INextHandler next, object message)
        {
            using (var transaction = unitOfWork.NewTransaction()) {
                return await next.Handle(message);
            }
        }
    }

Currently MicroBus only comes with built in support for Autofac.

For more examples check out the Enexure.MicroBus.Tests project or this sample WebApi project.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].