From a1420e41be4a82bcef213e730c4602bfdfe5e0be Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 2 Apr 2026 15:49:06 +0800 Subject: [PATCH 1/2] docs: address copilot review feedback on dynamic events PR --- .../2026-03-23-Dynamic-Events-in-ABP/POST.md | 4 +++- .../Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md b/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md index 5bf893bf1b..631dff6b7f 100644 --- a/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md +++ b/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md @@ -120,13 +120,15 @@ public class PartnerOrderHandler : IDistributedEventHandler - **`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 scopeFactory = context.ServiceProvider.GetRequiredService(); + // Typed handler — receives OrderPlacedEto eventBus.Subscribe(); diff --git a/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs index 173d5a8531..efecb25b2b 100644 --- a/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs +++ b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs @@ -384,7 +384,7 @@ public class LocalDistributedEventBus_Test : LocalDistributedEventBusTestBase services.AddSingleton( new TestCounterService(() => handleCount++, () => disposeCount++)); services.AddTransient(); - var provider = services.BuildServiceProvider(); + using var provider = services.BuildServiceProvider(); var scopeFactory = provider.GetRequiredService(); using var subscription = DistributedEventBus.Subscribe( @@ -410,7 +410,7 @@ public class LocalDistributedEventBus_Test : LocalDistributedEventBusTestBase var services = new ServiceCollection(); services.AddSingleton(new TestCounterService(() => callCount++)); services.AddTransient(); - var provider = services.BuildServiceProvider(); + using var provider = services.BuildServiceProvider(); var scopeFactory = provider.GetRequiredService(); using var subscription = DistributedEventBus.Subscribe( From 418ace5e119eb5ef453008d3e36742db0e3c8795 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 2 Apr 2026 15:53:37 +0800 Subject: [PATCH 2/2] docs: add missing eventBus resolution in mixed handlers snippet --- .../Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md b/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md index 631dff6b7f..b69d14e1a8 100644 --- a/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md +++ b/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md @@ -127,6 +127,7 @@ public class PartnerOrderHandler : IDistributedEventHandler 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(); var scopeFactory = context.ServiceProvider.GetRequiredService(); // Typed handler — receives OrderPlacedEto