Imagine I have two services A and B, and one of the entities of A has a relation with some entity in B. Where should I place the checking logic?
I considered two options
- Use Ocelot API Gateway to check for Record existence before inserting
- Use async messaging where I insert the record and add a consistency flag at service A. Service A will publish an event: CheckExistanceEvent and listen to the event: RecordExistEvent published by B
I think both of my solutions are bad and introduce coupling. I have looked for solutions but nothing was clear to me.
Any suggestion on where I should check for record existence?