We have been using Rebus to send commands to Azure Service Bus. We have a project that spans environments and needs to send commands to two different ASB namespaces (different connection strings).
The way we currently register Rebus doesn't allow us to create a factory or use multiple namespaces (that I'm aware of).
Inside Startup.cs ConfigureServices(...) method:
services.AddRebus(config =>
{
var asbConfig = Configuration.GetSection("AzureServiceBusConfiguration").Get<AzureServiceBusConfiguration>();
config
.Logging(l => l.Serilog(Log.Logger))
.Transport(t => t.UseAzureServiceBusAsOneWayClient(asbConfig.ConnectionString))
.Routing(r => r.TypeBased().Map<MyCommand>($"{asbConfig.Environment}/myQueueName"));
return config;
});
I've tried attacking this from several different directions, and all have fallen short. Is there a supported way to register more than one IBus configuration with different connection strings?
We basically need to spin this up per request scope so we can configure Rebus based on a request header value. Not sure where to start with this.