Currently, I'm working on a project that using MicroServices as the main concept.
For a clearer picture, I'll give you the example:
I got Service A that has its own model and controller.
Basically, Service A only contains basic CRUD operations for Database A.
Second, I got Service B, same like Service A but different database (Database B).
Now, I created 1 Services to consume both Service A and Service B. Currently I'm using TransactionScope for 'wrap' the transaction, but it didn't work.
Here's the code :
//This is the service to call Service A and Service B
using (TransactionScope ts = new TransactionScope())
{
callServiceAMethod(); // works good
callServiceBMethod(); // something happened, and failed
//from here I don't know what should I do
//What I'm expecting is : if one of the service i just called didn't work as expected,
//the transaction will be rolled back else will committed
}
Any help will be appreciated :)