Browse Source

accept equal versions and update the document

pull/15134/head
Halil İbrahim Kalkan 4 years ago
parent
commit
634c830644
  1. 2
      docs/en/Distributed-Event-Bus.md
  2. 5
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntitySynchronizer.cs

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

@ -342,7 +342,7 @@ public class ProductSynchronizer : EntitySynchronizer<OrderProduct, Guid, Produc
The main point of this class is it subscribes to the create, update and delete events of the source entity and updates the local entity in the database. It uses the [Object Mapper](Object-To-Object-Mapping.md) system to create or update the `OrderProduct` objects from `ProductEto` objects. So, you should also configure the object mapper to make it properly works. Otherwise, you should manually perform the object mapping by overriding the `MapToEntityAsync(TSourceEntityEto)` and `MapToEntityAsync(TSourceEntityEto,TEntity)` methods in your `ProductSynchronizer` class.
`EntitySynchronizer` is compatible with the *Entity Versioning* system (see the [Entities document](Entities.md)). So, it works as expected even if the events are received as disordered. If the entity's version in your local database is newer than the entity in the received event, then the event is ignored.
`EntitySynchronizer` is compatible with the *Entity Versioning* system (see the [Entities document](Entities.md)). So, it works as expected even if the events are received as disordered. If the entity's version in your local database is newer than the entity in the received event, then the event is ignored. You should implement the `IHasEntityVersion` interface for the entity and ETO classes (for this example, you should implement for `Product`, `ProductEto` and `OrderProduct` classes).
If you want to ignore some type of change events, you can set `IgnoreEntityCreatedEvent`, `IgnoreEntityUpdatedEvent` and `IgnoreEntityDeletedEvent` in the constructor of your class. Example:

5
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EntitySynchronizer.cs

@ -161,7 +161,10 @@ public abstract class EntitySynchronizer<TEntity, TSourceEntityEto> :
{
if (localEntity is IHasEntityVersion versionedLocalEntity && eto is IHasEntityVersion versionedEto)
{
return Task.FromResult(versionedEto.EntityVersion > versionedLocalEntity.EntityVersion);
/* We are also accepting the same version because
* the entity may be updated, but the version might not be changed.
*/
return Task.FromResult(versionedEto.EntityVersion >= versionedLocalEntity.EntityVersion);
}
return Task.FromResult(true);

Loading…
Cancel
Save