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)
-
0
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?
-
0
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
-
0
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.
-
0
Ok
I try to check if this pattern can be use in our scenario