Open Closed

IDistributedEventHandler does not subscribe the event which is published by Identity while using module template #2806


User avatar
0
uyarbtrlp created
  • ABP Framework version: v5.1.4
  • UI type: MVC
  • DB provider: EF Core
  • Module Template: yes
  • Steps to reproduce the issue:"
  1. I've created the module template by using abp suite.
  2. I've used the Separated Deployment & Databases Scenario. Therefore, I've runned update-db.ps1 script in both HttpApi.Host and IdentityServer projects.
  3. I've runned the solution.
  4. I've created the TestUserHandler class under TestApplication.Domain and subscribe the UserEto.
  5. I've given a reference Volo.Abp.Users.Domain for using UserEto.
   public class TestUserHandler : IDistributedEventHandler<EntityCreatedEto<UserEto>>, ITransientDependency
    {

        private readonly ICurrentTenant _currentTenant;


        private readonly ILogger<TestUserHandler> _logger;


        public TestUserHandler( ICurrentTenant currentTenant, ILogger<TestUserHandler> logger)
        {
            _currentTenant = currentTenant;
            _logger = logger;
        }
        public virtual async Task HandleEventAsync(EntityCreatedEto<UserEto> eventData)
        {

            
        }
    }
  1. I couldn't subscribe the event while adding a new user.
  2. When I use the same structure on Single (Unified) Application Scenario, I can subscribe the event and see the data of new user. It is same for EntityUpdatedEto<UserEto>
  3. Do I need to add external packages or codes for getting the event data or is it a kind of bug? How can I resolve this?

5 Answer(s)
  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Did you follow this configuration document?

  • User Avatar
    0
    uyarbtrlp created

    Yes, of course. When I configure and map the object which is created by me like document you sent, I can subscribe the event. Like I mentioned, I couldn't subscribe events related with Identity such as creating a new user, creating a new role. Also, I can subscribe these events on Single (Unified) Application Scenario, but not on Separated Deployment & Databases Scenario. I realized above code block, somehow, didn't represent the handler which I created.

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Can you also check the rabbitmq-management page when an event is published to guarantee the event is published?

  • User Avatar
    0
    uyarbtrlp created

    I am using the LocalDistributedEventBus which is default.

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    I am using the LocalDistributedEventBus which is default.

    The user is created at IdentityServer and you are trying to handle it in an Http.Api.Host application. LocalDistributedEventBus works in-process. You need to use a distributed event bus provider like RabbitMq or Kafka.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38