Onur Gumus
Onur Gumus

Reputation: 1439

Two way communication for Restful Microservices, Is it reasonable for notification?

Many books and articles state that cycles in Micro services are usually bad since they introduce mutual interdependency, that in result causes bigger dependency, versioning and deployment problems to solve.

However, suppose that there is service A, calling service B, also suppose that since this call will initiate lengthy calculation so we should not make this call synchronous. A possible solution is service A passes a resource url to service B, so that when ever B calculates the result, it should post the result to the given url following restful paradigm. So this final resource is like some sort of callback. This approach indeed would solve my problem however as explained in the above paragraph it introduces a cyclic dependency. Is this okay? if not how else you would solve the same problem ?

Upvotes: 0

Views: 1591

Answers (1)

hB0
hB0

Reputation: 2037

Its OK but not a good design as you can see the dependency is pretty hard-coded.

You have a choice to use messaging where you put the request message in one queue and response message in another queue.

In this way your communication will be asynchronous, loosely coupled, and none of the service would need to know very specifically about each other and their location/address. This is also the way to communicate as recommended by Reactive Manifesto.

Upvotes: 1

Related Questions