0

I'd like some insight/heuristics on how to tackle a specific kind of situation.

Entity A, B have a parent child relationship with Entity C. Entity A creation is done thru a POST /createA API in Microservice1 and this microservice has APIs to update, edit and delete an instance of A as well. Entity C create is done thru a POST /createC API in Microservice2 and this microservice has APIs to update, edit and delete an instance of C as well.

It is not an option to migrate creation logic of A,B,C into a single component and Microservice1 owns Entity A, while Microservice2 owns Entity C;

Consider the scenario, where a POST /createA call is made with incorrect data provided for Entity C.

Do we fail the entire request, or do we create A with No reference to C, with an appropriate HTTP status; given that we cannot verify if Entity C is valid without making a call to POST /createC

2

2 Answers 2

0

You should create A, and should return 200, with additional message, stating that C could not be created.

so again C creation can be tried with A's id sent.

0

This might not be the kind of answer you expect. Or anyone reading this might expect, but to me, the question was made to the wrong audience.

Whether A without C or A with a wrong C reference is valid or not, we can not say. Only your business experts will know because the relationship between A and C does respond to a need originated by the business.

Business experts will know if A can exist without C. If it can exist without, but temporally. If there's a compensative operation to fix wrong references A.C, etc.

Once they clear this doubt (the what to do), then comes the how to do it and that's the kind of question we can help you out with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.