Browse Source

Update Distributed-Event-Bus.md

pull/14197/head
gdlcf88 4 years ago
parent
commit
3ad093f696
  1. 50
      docs/en/Distributed-Event-Bus.md

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

@ -499,6 +499,56 @@ Configure<AbpDistributedEventBusOptions>(options =>
});
````
## Entity Synchronizer
Todo: introdution.
### Create a Synchronizer Class
Todo.
```csharp
public class BlogUserSynchronizer : EntitySynchronizer<BlogUser, Guid, UserEto>, ITransientDependency
{
public BlogUserSynchronizer(IObjectMapper objectMapper, IRepository<BlogUser, Guid> repository) :
base(objectMapper, repository)
{
}
}
```
### Advanced Usages
We may want to skip synchronizing the entity data on the external entity created, updated, or deleted. The `EntitySynchronizer` has three bool properties to control the handling behaviors.
```csharp
public class BlogUserSynchronizer : EntitySynchronizer<BlogUser, Guid, UserEto>, ITransientDependency
{
protected override bool IgnoreEntityCreatedEvent => true;
protected override bool IgnoreEntityUpdatedEvent => true;
protected override bool IgnoreEntityDeletedEvent => true;
// ctor ...
}
```
### Eventual Consistency Guarantee
Developers should always handle the distributed events disordering. ABP framework has an `EntityVersion` audit property to avoid an old version of entity data overriding a new one.
The only thing we need to do is make the entity implement the `IHasEntityVersion` interface.
```csharp
public class User : Entity<Guid>, IHasEntityVersion
{
public int EntityVersion { get; set; }
}
```
After that, the entity synchronizer will know the entity version number and skip handling the stale events.
> See the community post [Notice and Solve ABP Distributed Events Disordering](https://community.abp.io/posts/notice-and-solve-abp-distributed-events-disordering-yi9vq3p4) for more if you are interested or worried.
## See Also
* [Local Event Bus](Local-Event-Bus.md)

Loading…
Cancel
Save