Quantcast
Channel: CQRS Archives - CodeOpinion
Viewing all articles
Browse latest Browse all 65

MicroBus: In-Process Mediator

$
0
0

I’ve blogged about the mediator pattern a lot.  Primarily because it’s been a good fit in several of the applications I’ve developed over the last few years.

Mediator Pattern

For those completely unfamiliar with the mediator pattern, here’s a brief summary:

With the mediator pattern, communication between objects is encapsulated with a mediator object. Objects no longer communicate directly with each other, but instead communicate through the mediator. This reduces the dependencies between communicating objects, thereby lowering the coupling.

Libraries

I’ve written my own implementations of the mediator library from project to project.  Once I finally found the MediatR library, I’ve pretty much been using it instead of my own.

In a recent post about MediatR v3’s new Behaviors, Daniel Little commented about his implementation called MicroBus.

I love checking out new libraries to see what’s out there.  I’ve gotten a lot of feedback about other OSS libraries and tools I’ve blogged about.

I figured this was a good opportunity to mention library that look pretty interesting and may be worth taking a deeper look at.

MicroBus

This library actually looks more like what I’ve built myself in the past.

The first thing to notice is there are two separate interfaces for defining a Command or a Query.

View the code on Gist.

There isn’t anything surprising when you look at implement your handlers.  It’s pretty straight forward and what you would expect.  Familiar things are nice.

View the code on Gist.

Cross Cutting Handlers

What’s really interesting is how it handles cross cutting concerns.  You can create global handlers via the IDelegatedHandler interface or create a pipeline with IPipeline interface.

View the code on Gist.

BusBuilder

Another interesting aspect is how you build up registering your handlers.  There is built in support for Autofac

View the code on Gist.

Comments

From the looks of it MicroBus looks like a pretty nice implementation of the mediator pattern with a lot of features people are looking for such as pipelines.

Check it out on GitHub.  It is a very active project (as of this posting).

If you want to see a real world demo, possibly of my MusicStore sample app but using MicroBus, please let me know!

If you have another library you would like me to blog about feel please let me know in the comments or on Twitter.


The post MicroBus: In-Process Mediator appeared first on CodeOpinion.


Viewing all articles
Browse latest Browse all 65

Trending Articles