Best practice to delete entity in microservice architecture #17301
Replies: 1 comment 1 reply
-
Hi, actually this question is not fully related to ABP Framework but microservices. However, I will try to guide you and share what I would do. Whenever you need to delete a record from a microservice (the source of truth for the related data), you can use the Transactional Outbox Pattern and add the ..DeletedEvent as the event name to the outbox table to prevent possible problems (like the transaction being able to be committed, but the related event could not be published) and commit the change in a single transaction (both deleting a record from a database and inserting an event record to the outbox table should happen in a single transaction). ABP's Outbox Pattern will be sent the event to the actual message broker by a separate background worker with a re-try system. In this way, it ensures consistency between your database state and the published events. Then, the only thing you need to do is, subscribe to the event and delete the record in the other microservices. You can use this approach to sync your data (local copies) between microservices. |
Beta Was this translation helpful? Give feedback.
-
In our microservice solution, we have multiple databases. Let's consider one of the databases, called "Database_1," which contains a table named "BaseInformation." The data from this table is also utilized in other databases.
Our goal is to prevent users from deleting any row from the "BaseInformation" table if it is referenced in other tables. To achieve this, we need to implement this logic using best practices in the ABP Framework.
Any ideas ?
Beta Was this translation helpful? Give feedback.
All reactions