Barcelona
Barcelona

Reputation: 2132

Handling UI in Event-driven Microservices

I have concern when handling communication between Frontend and Backend in Event-Driven Microservices architecture:

Use case: User creates new product then he go to product list to check. The flow will be as below enter image description here

My question is how the UI handle product list in this case? The new product may not be present because the read side haven't processed new product event.

Upvotes: 8

Views: 2529

Answers (1)

Imran Arshad
Imran Arshad

Reputation: 4002

That's possible since you are using CQRS Pattern. Generally in distributed system we prefer eventual consistency over strong consistency to make it scale-able. So there's a trade-off.

In your scenario really depends how long it would take to reflect change from Write to read database but i assume it shouldn't be long. If it is then you have to manage it accordingly on UI end e.g. As soon as your enter the product in your system you may need to return ID, that your UI would poll in read database and meanwhile user has wait screen. Or better you may have to use Websockets to avoid polling and update UI as soon as product is available on read side

Upvotes: 2

Related Questions