Browse Source

Merge pull request #23614 from abpframework/auto-merge/rel-9-3/3959

Merge branch dev with rel-9.3
pull/23619/head
Ma Liming 1 year ago
committed by GitHub
parent
commit
f3e77eb9ba
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 18
      framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/AbpEventBusRebusModule.cs
  2. 6
      framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/AbpRebusEventBusOptions.cs

18
framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/AbpEventBusRebusModule.cs

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

6
framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/AbpRebusEventBusOptions.cs

@ -10,10 +10,10 @@ namespace Volo.Abp.EventBus.Rebus;
public class AbpRebusEventBusOptions public class AbpRebusEventBusOptions
{ {
[NotNull] public string InputQueueName { get; set; } = null!;
public string InputQueueName { get; set; } = default!;
public string RebusInstanceName { get; set; } = "default-instance";
[NotNull]
public Action<RebusConfigurer> Configurer { public Action<RebusConfigurer> Configurer {
get => _configurer; get => _configurer;
set => _configurer = Check.NotNull(value, nameof(value)); set => _configurer = Check.NotNull(value, nameof(value));

Loading…
Cancel
Save