diff --git a/docs/en/Distributed-Event-Bus.md b/docs/en/Distributed-Event-Bus.md index f1b8464d59..550ea6d9f8 100644 --- a/docs/en/Distributed-Event-Bus.md +++ b/docs/en/Distributed-Event-Bus.md @@ -185,6 +185,51 @@ If you perform **database operations** and use the [repositories](Repositories.m > The handler class must be registered to the dependency injection (DI). The sample above uses the `ITransientDependency` to accomplish it. See the [DI document](Dependency-Injection.md) for more options. +## Monitoring Distributed Events + +The ABP Framework allows you to stay informed when your application **receives** or **sends** a distributed event. This capability enables you to track the event flow within your application and take appropriate actions based on the received or sent distributed events. + +### Received Events + +The `DistributedEventReceived` local event is published when your application receives an event from the distributed event bus. `DistributedEventReceived` class has the following fields: + +- **`Source`:** It represents the source of the distributed event. Source can be `Direct`, `Inbox`, `Outbox`. +- **`EventName`:** It represents the [name](#event-name) of the event received. +- **`EventData`:** It represents the actual data associated with the event received. Since it is of type `object`, it can hold any type of data. + +**Example: Get informed when your application receives an event from the distributed event bus** + +```csharp +public class DistributedEventReceivedHandler : ILocalEventHandler, ITransientDependency +{ + public async Task HandleEventAsync(DistributedEventReceived eventData) + { + // TODO: IMPLEMENT YOUR LOGIC... + } +} +``` + +### Sent Events + +The `DistributedEventSent` local event is published when your application sends an event to the distributed event bus. `DistributedEventSent` class has the following fields: + +- **`Source`:** It represents the source of the distributed event. Source can be `Direct`, `Inbox`, `Outbox`. +- **`EventName`:** It represents the [name](#event-name) of the event sent. +- **`EventData`:** It represents the actual data associated with the event sent. Since it is of type `object`, it can hold any type of data. + +**Example: Get informed when your application sends an event to the distributed event bus** + +```csharp +public class DistributedEventSentHandler : ILocalEventHandler, ITransientDependency +{ + public async Task HandleEventAsync(DistributedEventSent eventData) + { + // TODO: IMPLEMENT YOUR LOGIC... + } +} +``` + +You can seamlessly integrate event-tracking capabilities into your application by subscribing to the `DistributedEventReceived` and `DistributedEventSent` local events as above examples. This empowers you to effectively monitor the messaging flow, diagnose any potential issues, and gain valuable insights into the behavior of your distributed messaging system. ## Pre-Defined Events