Browse Source

Merge pull request #25203 from abpframework/auto-merge/rel-10-3/4471

Merge branch dev with rel-10.3
pull/25214/head
Volosoft Agent 1 month ago
committed by GitHub
parent
commit
da7fa66ced
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md
  2. 4
      framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs

5
docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md

@ -120,13 +120,16 @@ public class PartnerOrderHandler : IDistributedEventHandler<DynamicEventData>
- **`EventName`** — the string name that identifies the event
- **`Data`** — the raw event data payload (the deserialized `object` from the broker)
> `Subscribe` returns an `IDisposable`. Call `Dispose()` to unsubscribe the handler at runtime. For application-lifetime subscriptions, prefer module initialization (`OnApplicationInitializationAsync`) over subscribing inside an application service.
> `Subscribe` returns an `IDisposable`. Call `Dispose()` to unsubscribe the handler at runtime. For application-lifetime subscriptions, prefer module initialization (`OnApplicationInitialization` / `OnApplicationInitializationAsync`) over subscribing inside an application service.
## Mixed Typed and Dynamic Handlers
Typed and dynamic handlers coexist naturally. When both are registered for the same event name, **both are triggered** — the framework automatically converts the data to the appropriate format for each handler.
```csharp
var eventBus = context.ServiceProvider.GetRequiredService<IDistributedEventBus>();
var scopeFactory = context.ServiceProvider.GetRequiredService<IServiceScopeFactory>();
// Typed handler — receives OrderPlacedEto
eventBus.Subscribe<OrderPlacedEto, OrderEmailHandler>();

4
framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs

@ -384,7 +384,7 @@ public class LocalDistributedEventBus_Test : LocalDistributedEventBusTestBase
services.AddSingleton<ITestCounterService>(
new TestCounterService(() => handleCount++, () => disposeCount++));
services.AddTransient<DynamicIocEventHandlerWithCounter>();
var provider = services.BuildServiceProvider();
using var provider = services.BuildServiceProvider();
var scopeFactory = provider.GetRequiredService<IServiceScopeFactory>();
using var subscription = DistributedEventBus.Subscribe(
@ -410,7 +410,7 @@ public class LocalDistributedEventBus_Test : LocalDistributedEventBusTestBase
var services = new ServiceCollection();
services.AddSingleton<ITestCounterService>(new TestCounterService(() => callCount++));
services.AddTransient<DynamicIocEventHandlerWithService>();
var provider = services.BuildServiceProvider();
using var provider = services.BuildServiceProvider();
var scopeFactory = provider.GetRequiredService<IServiceScopeFactory>();
using var subscription = DistributedEventBus.Subscribe(

Loading…
Cancel
Save