abuzaforfagun / Invoice.Microservices.ThirdPartyAPIIntegration

Scaleable fault tolerance microservices to communicate third party API
9 stars 3 forks source link

Remove single point of failure #2

Closed abuzaforfagun closed 2 years ago

abuzaforfagun commented 2 years ago

InvoiceReader service is dependent on InvoiceProcessor. As NewInvoiceAddedHandler is making HTTP requests to InvoiceProcessor to get the status of the invoice. When InvoiceProcessor is unreachable, InvoiceProcessor would fail to remove the cache. It could be a single point of failure.

We need to remove the direct dependency of InvoiceProcessor from the InvoiceReader service.

abuzaforfagun commented 2 years ago

Previously I used to call InvoiceProcessor from NewInvoiceAddedHandler to make sure the invoice is already processed or not.

Because, inside SendInvoice command handler, I fire the NewInvoiceAdded first and call the client afterward.

There is a reason behind this, our distributed handler call could fail because of network latency or when the Azure server is down. We did not follow any way around to revert that service bus call.

But we can use the nested transactions to fix the issue and it will remove the necessity to call the Invoice Processor service from Invoice Reader.