0
votes

Lets see I have a microservices A,B,C and D, which communicate asynchronously using message broker (Kafka). if service A is UI facing service accept synchronous request for a transaction which depend on B and C. now here service A put a message in message broker queue which is already having some message to process then request has to wait till we get response from other services. how would you design this type of microservice communication ? if we required both type of communication synchronous and asynchronous.

1

1 Answers

0
votes

how would you design this type of microservice communication?

It depends. Synchronous communication as you describe is using a request-response pattern while the asynchronous communication usually (not always) use a publish-subscribe pattern in situations like yours.

Whether you can or can not use a request-response pattern depends on your requirements of response time.

Whether you can or can not use a publish-subscribe in your UI facing service depends on technical requirements, e.g. if you can use a library like gRPC, RSocket, an MQTT client or something else with pub-sub semantics.

For me, it feels more natural to use any kind of pub-sub protocol in these situations.