Starts in:
2 DAYS
6 HRS
57 MIN
18 SEC
Starts in:
2 D
6 H
57 M
18 S
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
    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
    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 v9.1.0-preview. Updated on November 20, 2024, 13:06