Monthly Archive 2019-01-29

ByMogens

Generic host

Over the years, people have often asked me if Rebus had a “generic host”, similar to NServiceBus’ Generic Host. In case you don’t know, NServiceBus’ generic host is a library that helps you easily get an NServiceBus endpoint up and running as a Windows Service.

Rebus doesn’t have a generic host though – and there’s a good reason for that! πŸ™‚

The reason is, that there’s no reason why the Windows Service host should in any way be Rebus-specific!

What you really want in a Windows Service host (and in any host, really) is just a simple model for initializing something, keeping it around for the duration of the program’s lifetime, with proper termination at the end.

The cool thing is that .NET has great built-in mechanisms for initializing and terminating things – they’re called CONSTRUCTORS and IDisposable!

So what if a Windows Service could be composed of something, that should simply be newed up and disposed afterwards? And what if the hosting library made it possible to also run the app as an Azure Web Job? And what if it could host any number of “things”?

That’s what Topper does! 😎

Topper is built on Topshelf, so that means F5-debugging as a Console Application, and the ability to be installed as a Windows Service.

In addition to this, Topper will detect if it’s running as an Azure Web Job and do what’s necessary to shut down cleanly.

This is what your program can look like with Topper:

class Program
{
    static void Main()
    {
        var configuration = new ServiceConfiguration()
            .Add("first", () => new MyFirstService())
            .Add("second", () => new MySecondService());

        ServiceHost.Run(configuration);                
    }
}

ServiceConfiguration allows for adding any number of named factories, each returning an IDisposable, and async factories (Func<Task<IDisposable>>) are supported, too.

As you can see, there’s no good reason why a “generic host” should be tied to any particular service bus library…Β so that’s why Rebus does not have a generic host. πŸ€“

ByMogens

MongoDB database migration

When you’re developing a fairly large application, and you design things properly, you will almost inevitably end up distilling out some nice things into independent, well-factored libraries – because, Separation of Concerns, you know… πŸ€“

That also happened this Friday, when Fleet Manager got its evolutionary database design library for MongoDB moved out into its own project: Mongrow.

With Mongrow, you can write database migrations as C# classes and have them executed in a safe, consistent, and deterministic manner, probably when your application starts up.

Its design is very much inspired by migr8, another little database migration library, only made for MSSQL and Postgres.

So… if you’re using MongoDB in .NET, you might want to check it out: The binaries are on NuGet.org.

ByMogens

We have a mailing list

If you’re interested in receiving weekly emails with little nuggets of Rebus wisdom, go here and sign up! πŸ’Œ

ByMogens

Meet Afonso

Hi everyone, meet Afonso!

Having finished a secondary school professional programme within Computing, he came to Denmark two years ago from his home island of Madeira in Portugal, to pursue an AP degree in IT Technology at Dania Academy in Viborg. πŸŽ“

Afonso has now moved to Horsens to do his final internship here at Rebus FM, where he will spend most of his time performing a security review of Fleet Manager. 🚌

In addition to this, it’s already quite clear that he will inspire Alley 87‘s residents to extend #skalerbar‘s assortment of beverages into the territory of fortified wines, which we’re looking forward to. 🍷