|
|
|
@ -1,8 +1,10 @@ |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Rebus.Config; |
|
|
|
using Rebus.Handlers; |
|
|
|
using Rebus.Pipeline; |
|
|
|
using Rebus.Pipeline.Receive; |
|
|
|
using Rebus.ServiceProvider; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
|
|
|
|
namespace Volo.Abp.EventBus.Rebus; |
|
|
|
@ -16,11 +18,12 @@ public class AbpEventBusRebusModule : AbpModule |
|
|
|
context.Services.AddTransient(typeof(IHandleMessages<>), typeof(RebusDistributedEventHandlerAdapter<>)); |
|
|
|
|
|
|
|
var preActions = context.Services.GetPreConfigureActions<AbpRebusEventBusOptions>(); |
|
|
|
Configure<AbpRebusEventBusOptions>(rebusOptions => |
|
|
|
var rebusOptions = preActions.Configure(); |
|
|
|
Configure<AbpRebusEventBusOptions>(options => |
|
|
|
{ |
|
|
|
preActions.Configure(rebusOptions); |
|
|
|
preActions.Configure(options); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
context.Services.AddRebus(configure => |
|
|
|
{ |
|
|
|
configure.Options(options => |
|
|
|
@ -34,9 +37,9 @@ public class AbpEventBusRebusModule : AbpModule |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
preActions.Configure().Configurer?.Invoke(configure); |
|
|
|
rebusOptions.Configurer?.Invoke(configure); |
|
|
|
return configure; |
|
|
|
}); |
|
|
|
}, startAutomatically: false, key: rebusOptions.RebusInstanceName); |
|
|
|
} |
|
|
|
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|
|
|
@ -46,6 +49,7 @@ public class AbpEventBusRebusModule : AbpModule |
|
|
|
.GetRequiredService<RebusDistributedEventBus>() |
|
|
|
.Initialize(); |
|
|
|
|
|
|
|
context.ServiceProvider.StartRebus(); |
|
|
|
var rebusOptions = context.ServiceProvider.GetRequiredService<IOptions<AbpRebusEventBusOptions>>().Value; |
|
|
|
context.ServiceProvider.GetRequiredService<IBusRegistry>().StartBus(rebusOptions.RebusInstanceName); |
|
|
|
} |
|
|
|
} |
|
|
|
|