Open Closed

OrganizationUnit Update events are not published #7412


User avatar
0
WaelRazouk created
  • ABP Framework version: v8.1.1
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I have the micro-service architecture.

Follow the steps described in https://docs.abp.io/en/abp/latest/Distributed-Event-Bus#entity-synchronizer and try to synchronize OrganizationUnit (so I can have a replica of the table in my custom service)

Here is the synchronizer class


public class CssDepartmentSynchronizer :
    EntitySynchronizer<CssDepartment, OrganizationUnitEto>
{

    private readonly ILogger<CssDepartmentSynchronizer> _logger;

    public CssDepartmentSynchronizer(
        IObjectMapper objectMapper, 
        IRepository<CssDepartment> repository,
        ILogger<CssDepartmentSynchronizer> logger) : base(objectMapper, repository)
    {
        _logger = logger;
    }

    public override Task HandleEventAsync(EntityCreatedEto<OrganizationUnitEto> eventData)
    {
        _logger.LogInformation("CssDepartmentSynchronizer EntityCreatedEto");
        return base.HandleEventAsync(eventData);
    }

    public override Task HandleEventAsync(EntityDeletedEto<OrganizationUnitEto> eventData)
    {
        _logger.LogInformation("CssDepartmentSynchronizer EntityDeletedEto");
        return base.HandleEventAsync(eventData);
    }

    public override Task HandleEventAsync(EntityUpdatedEto<OrganizationUnitEto> eventData)
    {
        _logger.LogInformation("CssDepartmentSynchronizer EntityUpdatedEto");
        return base.HandleEventAsync(eventData);
    }

    protected override async Task<CssDepartment?> FindLocalEntityAsync(OrganizationUnitEto eto)
    {
        _logger.LogInformation("CssDepartmentSynchronizer FindLocalEntityAsync");
        var entity = await Repository.FindAsync(d => d.Id  == eto.Id);
        if (entity == null)
            _logger.LogInformation("CssDepartmentSynchronizer not found");
        else
            _logger.LogInformation("CssDepartmentSynchronizer found");
        return entity;
    }
}

This class is not being hit (no logs added to the logs file). Similar code for IdentityUser works fine

public class CssUserSynchronizer :
 EntitySynchronizer<CssUser, UserEto>

2 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Did you configure the AutoEventSelectors

    Configure<AbpDistributedEntityEventOptions>(options =>
    {
        options.AutoEventSelectors.Add<OrganizationUnit>();
        options.EtoMappings.Add<OrganizationUnit, OrganizationUnitEto>();
    });
    
  • User Avatar
    0
    WaelRazouk created

    Hi,

    Did you configure the AutoEventSelectors

    Configure<AbpDistributedEntityEventOptions>(options => 
    { 
        options.AutoEventSelectors.Add<OrganizationUnit>(); 
        options.EtoMappings.Add<OrganizationUnit, OrganizationUnitEto>(); 
    }); 
    

    Hi, yes in my DomainModule, here is the ConfigureServices method

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        base.ConfigureServices(context);
        Configure<AbpDistributedEntityEventOptions>(options =>
        {
            options.AutoEventSelectors.Add<OrganizationUnit>();
            options.EtoMappings.Add<OrganizationUnit, OrganizationUnitEto>();
        });
    }
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11