Rebus.SimpleInjector
9.0.0-alpha01
See the version list below for details.
dotnet add package Rebus.SimpleInjector --version 9.0.0-alpha01
NuGet\Install-Package Rebus.SimpleInjector -Version 9.0.0-alpha01
<PackageReference Include="Rebus.SimpleInjector" Version="9.0.0-alpha01" />
paket add Rebus.SimpleInjector --version 9.0.0-alpha01
#r "nuget: Rebus.SimpleInjector, 9.0.0-alpha01"
// Install Rebus.SimpleInjector as a Cake Addin #addin nuget:?package=Rebus.SimpleInjector&version=9.0.0-alpha01&prerelease // Install Rebus.SimpleInjector as a Cake Tool #tool nuget:?package=Rebus.SimpleInjector&version=9.0.0-alpha01&prerelease
Rebus.SimpleInjector
Provides a SimpleInjector-based container adapter for Rebus.
To configure Rebus to work with your SimpleInjector container, simply call
container.RegisterRebus(
configurer => configurer
.(...)
);
where the (...)
is the part usually omitted from the Rebus configuration examples.
A slightly more realistic example (using Serilog, RabbitMQ and SQL Server) could look like this:
var rabbitMqConnectionString = "amqp://rebususer:blablasecret@BIGRABBIT01.local";
var sqlServerConnectionString = "server=SQLMOTEL01.local; database=RebusStuff; trusted_connection=true";
container.RegisterRebus(
configurer => configurer
.Logging(l => l.Serilog())
.Transport(t => t.UseRabbitMq(rabbitMqConnectionString, "simpleinjectortest"))
.Sagas(s => s.StoreInSqlServer(sqlServerConnectionString, "Sagas", "SagaIndex"))
);
The examples shown so far will make the necessary container registrations, but the bus will not be started until either
- The container resolves the
IBus
instance, or - You call the
container.StartBus()
extension method
so you should probably always remember to call container.StartBus()
when your application starts (after it has
finished making ALL of its container registrations).
If you would like to be able to resolve IBus
WITHOUT starting consuming messages, you can set startAutomatically
to false
when configuring it like so:
container.RegisterRebus(
configurer => configurer
.Transport(...),
startAutomatically: false
);
which will configure the bus to have 0 workers when it's resolved from the container. You must then call
container.StartBus();
to start it.
So why is it different from all the other container adapters?
Because SimpleInjector is very opinionated about its registration API and Rebus is pretty loose about it 😃
How to register handlers?
Since Rebus' container adapters resolve ALL handlers that can handle an incoming message, handlers must be registered with the registration API for collections, e.g. like
container.Collection.Register<IHandleMessages<SomeMessage>>(typeof(SomeMessageHandler));
Due to limitations in SimpleInjector, you must be sure that all handlers for a given message type get registered with a single registration call similar to the one above.
There also exists a couple of extension methods that help you register handlers (up to three per message type) just the right way:
// one message handler
container.RegisterHandlers<SomeMessage, SomeMessageHandler>();
// two handlers of SomeMessage
container.RegisterHandlers<SomeMessage, SomeMessageHandler, AnotherMessageHandler>();
// three handlers of SomeMessage
container.RegisterHandlers<SomeMessage, SomeMessageHandler, AnotherMessageHandler, YetAnotherMessageHandler>();
The advantage of using Rebus' configuration extension is that it's easier to get right, because the extension will register it the right way in the container, and
the API uses C# generics constraints to validate that the given handler types do in fact implement IHandleMessages<>
closed with the right type.
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. |
.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
- Rebus (>= 8.0.0-alpha01)
- simpleinjector (>= 5.4.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Rebus.SimpleInjector:
Package | Downloads |
---|---|
RAES.Core
Package Description |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Rebus.SimpleInjector:
Repository | Stars |
---|---|
rebus-org/RebusSamples
Small sample projects
|
Version | Downloads | Last updated |
---|---|---|
9.0.0 | 7,190 | 11/15/2023 |
9.0.0-alpha01 | 137 | 3/29/2023 |
8.0.1 | 7,743 | 1/11/2023 |
8.0.0 | 9,434 | 2/3/2022 |
7.0.0 | 27,534 | 7/27/2020 |
6.0.0 | 5,993 | 3/15/2020 |
5.0.0-b02 | 5,278 | 4/19/2018 |
5.0.0-b01 | 10,029 | 8/28/2017 |
4.0.0 | 35,119 | 8/15/2017 |
4.0.0-b05 | 840 | 6/22/2017 |
4.0.0-b04 | 844 | 5/31/2017 |
4.0.0-b03 | 800 | 5/18/2017 |
4.0.0-b01 | 787 | 5/1/2017 |
3.0.0 | 24,676 | 1/5/2017 |
2.0.0 | 3,422 | 9/20/2016 |
2.0.0-b01 | 800 | 9/9/2016 |
0.99.74 | 1,012 | 8/29/2016 |
0.99.73 | 1,122 | 8/12/2016 |
0.99.72 | 1,041 | 8/4/2016 |
0.99.71 | 1,270 | 8/3/2016 |
0.99.70 | 1,193 | 7/29/2016 |
0.99.68 | 1,073 | 7/18/2016 |
0.99.67 | 1,049 | 7/1/2016 |
0.99.66 | 1,047 | 6/28/2016 |
0.99.65 | 1,053 | 6/23/2016 |
0.99.64 | 1,014 | 6/22/2016 |
0.99.63 | 1,018 | 6/21/2016 |
0.99.62 | 1,286 | 6/17/2016 |
0.99.61 | 1,030 | 6/17/2016 |
0.99.60 | 1,165 | 6/15/2016 |
0.99.59 | 1,030 | 6/3/2016 |
0.99.58 | 1,029 | 5/24/2016 |
0.99.57 | 1,041 | 5/22/2016 |
0.99.56 | 1,054 | 5/22/2016 |
0.99.55 | 1,009 | 5/16/2016 |
0.99.54 | 1,016 | 5/12/2016 |
0.99.53 | 1,025 | 5/12/2016 |
0.99.52 | 1,049 | 5/11/2016 |
0.99.51 | 1,007 | 5/9/2016 |
0.99.50 | 1,140 | 4/13/2016 |
0.99.48 | 1,066 | 4/6/2016 |
0.99.47 | 1,087 | 3/31/2016 |
0.99.46 | 1,063 | 3/30/2016 |
0.99.45 | 1,048 | 3/29/2016 |
0.99.44 | 1,070 | 3/26/2016 |
0.99.43 | 1,046 | 3/26/2016 |
0.99.42 | 1,046 | 3/22/2016 |
0.99.41 | 1,039 | 3/17/2016 |
0.99.40 | 1,054 | 3/15/2016 |
0.99.39 | 1,040 | 3/14/2016 |
0.99.38 | 1,024 | 3/9/2016 |
0.99.37 | 1,026 | 3/9/2016 |
0.99.36 | 1,054 | 3/3/2016 |
0.99.35 | 1,057 | 2/22/2016 |
0.99.34 | 1,059 | 2/19/2016 |
0.99.33 | 1,220 | 2/12/2016 |
0.99.32 | 1,046 | 2/10/2016 |
0.99.31 | 1,058 | 2/8/2016 |
0.99.30 | 1,038 | 2/5/2016 |
0.99.29 | 1,031 | 2/2/2016 |
0.99.27 | 1,055 | 1/28/2016 |
0.99.26 | 1,031 | 1/27/2016 |
0.99.25 | 1,046 | 1/22/2016 |
0.99.24 | 1,085 | 1/18/2016 |
0.99.23 | 1,093 | 12/18/2015 |
0.99.22 | 1,041 | 12/18/2015 |
0.99.21 | 1,041 | 12/11/2015 |
0.99.20 | 1,124 | 12/10/2015 |
0.99.19 | 1,059 | 12/8/2015 |
0.99.18 | 1,117 | 12/7/2015 |
0.99.17 | 1,058 | 12/7/2015 |
0.99.16 | 1,386 | 11/30/2015 |
0.99.14 | 1,142 | 11/24/2015 |
0.99.13 | 1,192 | 11/23/2015 |
0.99.12 | 1,187 | 11/17/2015 |
0.99.11 | 1,106 | 11/17/2015 |
0.99.10 | 1,110 | 11/11/2015 |
0.99.9 | 1,086 | 11/5/2015 |
0.99.8 | 1,084 | 11/5/2015 |
0.99.7 | 1,095 | 10/29/2015 |
0.99.5 | 1,052 | 10/27/2015 |
0.99.4 | 1,038 | 10/27/2015 |
0.99.2 | 1,113 | 10/12/2015 |
0.99.1 | 1,175 | 10/8/2015 |
0.99.0 | 1,206 | 10/7/2015 |
0.98.12 | 1,164 | 9/17/2015 |
0.98.11 | 1,116 | 9/17/2015 |
0.98.10 | 1,091 | 9/16/2015 |
0.98.9 | 1,119 | 9/14/2015 |
0.98.8 | 1,112 | 9/13/2015 |
0.98.7 | 1,080 | 9/9/2015 |
0.98.6 | 1,113 | 9/7/2015 |
0.98.5 | 1,085 | 9/3/2015 |
0.98.4 | 1,129 | 9/3/2015 |
0.98.3 | 1,095 | 9/1/2015 |
0.98.2 | 1,119 | 8/27/2015 |
0.98.0 | 1,079 | 8/26/2015 |
0.97.0 | 1,128 | 8/25/2015 |
0.96.0 | 1,072 | 8/24/2015 |
0.95.0 | 1,088 | 8/20/2015 |
0.94.0 | 1,064 | 8/19/2015 |
0.93.0 | 1,097 | 8/19/2015 |
0.92.4 | 1,090 | 8/17/2015 |
0.92.3 | 1,334 | 8/13/2015 |
0.92.2 | 1,932 | 8/12/2015 |
0.92.1 | 1,791 | 8/12/2015 |
0.92.0 | 1,215 | 8/11/2015 |
0.91.0 | 1,508 | 8/11/2015 |
0.90.9 | 1,584 | 8/10/2015 |
0.90.8 | 1,424 | 8/9/2015 |
0.90.7 | 1,414 | 8/5/2015 |
0.90.6 | 1,368 | 8/4/2015 |
0.90.5 | 1,282 | 8/4/2015 |
0.90.4 | 1,249 | 8/2/2015 |
0.90.3 | 1,254 | 8/2/2015 |
0.90.2 | 1,224 | 7/31/2015 |
0.90.1 | 1,208 | 7/29/2015 |
0.90.0 | 1,192 | 7/29/2015 |