Open Closed

Shared distributed Event #4205


User avatar
0
andmattia created

Hi

In my module I've a distributed event (es. new order created) so my handler catch it and write on Db the new data. Now I use my module in 2 application connected to my Bus. In this scenario I've more then 1 write process

  • one on my 1st appe
  • one on my second app

My goal is find a way to create handler for the event but enable / disable it to prevent multiple write data, which is the best way to do that?


4 Answer(s)
  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    As far as I understand, you have multiple handlers for the same event and you want to prevent adding the same data?

    How about quering the database first if the data exist already so you can skip inserting it?

  • User Avatar
    0
    andmattia created

    No I've only one handler but it's in a module that I use twice.

    Module product with handler ChangeProductHandler. I use this module on ERP and E-Commerce

    I've 1 database anche 2 separate API/UI

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    If you follow the DDD guides to set the ID when creating the entity with GuidGenerator instead of leaving to autogeneration, you can simply check the db before inserting it in the event handler. That will prevent same entity to get inserted.

  • User Avatar
    0
    andmattia created

    Ok

    I try to check if this pattern can be use in our scenario

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11