Open Closed

Creating/Modifying entities in Event Handlers #8995


User avatar
0
icoretchi created
  • Template: microservice

  • Created ABP Studio Version: 0.9.24

  • Current ABP Studio Version: 0.9.25

  • Multi-Tenancy: Yes

  • UI Framework: angular

  • Theme: leptonx

  • Theme Style: system

  • Run Install Libs: Yes

  • Database Provider: ef

  • Database Management System: sqlserver

  • Mobile Framework: none

  • Public Website: No

  • Include Tests: Yes

  • Dynamic Localization: Yes

  • Kubernetes Configuration: Yes

  • Grafana Dashboard: Yes

  • Use Local References: No

  • Optional Modules:

    • GDPR

    • FileManagement

    • TextTemplateManagement

    • AuditLogging

    • Chat

    • OpenIddictAdmin

  • Exception message and full stack trace:

  • Steps to reproduce the issue:

Hi,

I am publishing event in one microservice and listen in another. I've noticed that when I create or delete entities in the distributed event handlers the CreatorId or DeletorId record fields not added. Any ideas?

Thanks.


3 Answer(s)
  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    Hi,

    Can you send your entity contents and if you have a configuration for AbpDistributedEntityEventOptions?

  • User Avatar
    0
    icoretchi created

    Hi,

    I don't have configuration for AbpDistributedEntityEventOptions

    image.png
    image.png
    image.png

  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    Hi,

    CreatorId and DeletorId are auto-filled using ICurrentUser during HTTP requests. However, in distributed event handling, events are processed asynchronously in another microservice without the original HTTP context, so ICurrentUser data isn’t available, leaving these fields null. I suggest adding CreatorId and DeletorId to the ETO object when publishing the event and then setting them in the event handler as follows:

           test.CreatorId = eventData.Entity.CreatorId;
           test.DeleterId = eventData.Entity.DeleterId;
    
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 20, 2025, 09:50