Browse Source

Merge pull request #4768 from feanz/docs/add-unitofwork-details-to-eventhandlers

Add details on the correct use of unit of work in event handlers
pull/5011/head
Halil İbrahim Kalkan 6 years ago
committed by GitHub
parent
commit
df4ca0ab4b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      docs/en/Distributed-Event-Bus.md

3
docs/en/Distributed-Event-Bus.md

@ -178,8 +178,11 @@ That's all.
You can inject any service and perform any required logic here. A single event handler class can **subscribe to multiple events** but implementing the `IDistributedEventHandler<TEvent>` interface for each event type.
In your handler if you call a methods on a Repository you may find that you get an `ObjectDisposedException` being thrown. This will be because the unit of work being used by the Repository has been disposed in another context e.g. an ASP.net controller action. You will need to create a specific unit of work for your `HandleEventAsync` method. You can either use the `IUnitOfWorkManager.Begin` method or use the `UnitOfWorkAttribute` on the method. See the [Unit of work document](Unit-of-work.md) for more details.
> 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.
## Pre-Defined Events
ABP Framework **automatically publishes** distributed events for **create, update and delete** operations for an [entity](Entities.md) once you configure it.

Loading…
Cancel
Save