Installers in NServiceBus 3.0

In 3.0 we introduced the concept of installers to make sure that both infrastructure  and endpoint specific artifact installed and configured automatically for you if needed.

The installers comes in two flavors, infrastructure installers and regular installers. Infrastructure installers are used for things that are not specific to a given endpoint eg. RavenDB, MSMQ. Regular installers are focused on setting up things that the current endpoint is depending on eg. queues, folders, databases etc. Infrastructure installers are always invoked before regular installers. Although the installers are mainly used internally you could use the for your own purposed as well. Perhaps you need to make sure folders are created, database scripts invoked etc etc.

To create your own installer is as easy as implementing the INeedToInstallInfrastructure<T> interface. The generic parameter gives you a way to restrict your installer to a specific platform. Currently this is either Windows or Azure. If you don’t care about the environment use the INeedToInstallInfrastructure interface instead. To create a regular installer you just implement the INeedToInstallSomething<T> interface again using the T to restrict it to a specific environment.

NServiceBus will scan the assemblies in the runtime directory for installers so you don’t need any code to register them.

When are they invoked?

When using the NServiceBus host installers are invoked as follows:

Installers invoked

Command Line parameters

Infrastructure

Regular

/install NServiceBus.Production

                    √
NServiceBus.Production

×

×

/install NServiceBus.Integration

NServiceBus.Integration

×

/install NServiceBus.Lite

NServiceBus.Lite

×

As you can see the installers are controlled by both the /install command line option to the host and the current profile used. You can of course implement your own profile if you have other requirements.

When self hosting NServiceBus you have to invoke the installers manually using:

1 2 3
Configure.Instance
.ForInstallationOn<NServiceBus.Installation.Environments.Windows>()
.Install()
view raw RunCustomInstall.cs hosted with ❤ by GitHub

A full example can be found here.

Finally there is one final way to run the infrastructure installers. If you invoke the host with the /installInfrastructure flag the host will run only the infrastructure installers for you without requiring you to configure anything. This can be useful when you setup a new server or a developer machine since that verifies and installs the required infrastructure for NServiceBus to run. The RunMeFirst.bat included in the download is doing just that.

 

This entry was posted in NServiceBus. Bookmark the permalink. Both comments and trackbacks are currently closed.
  • Pingback: Using RavenDB in NServiceBus – Installing

  • Pingback: Builtin profiles in NServiceBus

  • http://profiles.google.com/johannesgu Johannes Gustafsson

    IMHO, infrastructure installers should only be installed explicitly. For example, if I call “NServicebus.Host /install NServiceBus.Production” and for some reason my own raven instance is not running or installed in some other way than the standard, it would install a new raven instance and put it in c:Program files. That would be a pretty unexpected side effect.

    • Anonymous

      Renember that we only install if no exlicit connection string is used and the install will also fail if there is another raven service installed. But we could check for existing services as we to make it more bullet proof.

  • http://profiles.google.com/johannesgu Johannes Gustafsson

    I especially don’t like the fact that there is no way to install the endpoint _only_. Maybe there should be a /installEndpoint flag that only calls regular installers? Also, /install could then be renamed to /installBoth

    • Anonymous

      You know what, that makes alot of sense. We already have a option to /installInfrastructure so we’ll build on that. This will hopefully make it into the next RC. Thanks!