Rebus.Microsoft.Extensions.Configuration
1.1.0
dotnet add package Rebus.Microsoft.Extensions.Configuration --version 1.1.0
NuGet\Install-Package Rebus.Microsoft.Extensions.Configuration -Version 1.1.0
<PackageReference Include="Rebus.Microsoft.Extensions.Configuration" Version="1.1.0" />
paket add Rebus.Microsoft.Extensions.Configuration --version 1.1.0
#r "nuget: Rebus.Microsoft.Extensions.Configuration, 1.1.0"
// Install Rebus.Microsoft.Extensions.Configuration as a Cake Addin #addin nuget:?package=Rebus.Microsoft.Extensions.Configuration&version=1.1.0 // Install Rebus.Microsoft.Extensions.Configuration as a Cake Tool #tool nuget:?package=Rebus.Microsoft.Extensions.Configuration&version=1.1.0
Rebus.Microsoft.Extensions.Configuration
Provides a Microsoft Extensions Configuration integration for Rebus.
In the newer incarnations of the .NET Framework, you're encouraged to configure your things via Microsoft.Extensions.Configuration.
While there's no doubt that the name is pretty silly, it's actually neatly designed, since it allows for picking up configuration from many different sources.
With Rebus.Microsoft.Extensions.Configuration you can have Rebus pick up your endpoint mappings from IConfiguration
😎
Let's say you have a configuration file, appsettings.json
, which looks like this:
{
"Mappings": {
"TestApp.Messages": "testapp-queue",
"AnotherApp.Messages": "anotherapp-queue"
}
}
If you're using Microsoft's generic host, then you should include the Rebus.ServiceProvider package too, because then you can configure your bus instance simply like this:
var host = Host.CreateDefaultBuilder()
.ConfigureServices((context, services) =>
{
services.AddRebus(
configure => configure
.Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "my-queue"))
.Routing(r => r.TypeBased().AddMappingsFromConfiguration(context.Configuration, "Endpoints"))
);
})
.Build();
host.Run();
If you are in place where the generic host is not available, you can still use the package in a slightly more manual way.
Start out by loading up your configuration file like this:
// build configuration
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
If we then want Rebus to pick up the endpoint mapping from it, we can do it like this:
Configure.With(...)
.Transport(...)
.Routing(r => r.TypeBased().AddMappingsFromConfiguration(configuration, "Mappings"))
.Start();
As you can see, we reference the Mappings
object in the JSON by specifying it as an argument to AddMappingsFromConfiguration
.
Since configuration can be loaded from many different sources, you just need to ensure that your mappings can be bound to a Dictionary<string, string>
.
It even works with environment variables! You can make Microsoft.Extensions.Configuration load your environment variables like this:
var configuration = new ConfigurationBuilder()
.AddEnvironmentVariables()
.Build();
and then, if you configured the following variable:
RebusMappings:TestApp.Messages = some-queue
then it can be picked up like this:
Configure.With(...)
.Transport(...)
.Routing(r => r.TypeBased().AddMappingsFromConfiguration(configuration, "RebusMappings"))
.Start();
which is super neat. 🙂
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- microsoft.extensions.configuration (>= 6.0.0 && < 10.0.0)
- microsoft.extensions.configuration.binder (>= 6.0.0 && < 10.0.0)
- rebus (>= 8.6.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.