1

My question raised because I have read some online resources, that claimed that Event-Driven Architecture seems better then using REST https://solace.com/blog/experience-awesomeness-event-driven-microservices/

So I try to re-design my Rest based application to implement some messaging system, but I am not sure how can it work with MVC

when each services use Rest-API to communicate, then the structure like:

HTML view -> MVC controller -> controller send request Service A -> Service A return response to controller -> HTML view

but if I tried implement publish-subscribe (I am using Spring Cloud Stream and Kafka), I do not understand how can my "correct" user can receive the response. because I think when there are 2 different users:

my diagram to show my problem

Please see the image, I am not sure how, after my controller receive the message from the topic, can route to the correct user. I tried to use "consumer group" but it seems not the solution because it can only specific which "service instance" to handle the message, but here, my MVC application is the service instance but with different connections (different user)

I have tried my best to explain my problem, I am not good in English, please let me know if you need me to express more.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224
DavidH
  • 11
  • 1
  • The one doesn't exclude the other. Your web part can still be request-response while the rest of your application uses publish-subscribe. It isn't an all or nothing solution, you should actually mix and match. If you really want to use pub/sub in the web stuff you should use SSE or WebSockets . – M. Deinum Apr 09 '19 at 05:32
  • Hi M.Deinum, could you give me some guideline, when is better to use Rest-API based, and when is better to use pub/sub? – DavidH Apr 10 '19 at 01:41
  • As stated the use of one doesn't exclude the use of the other. – M. Deinum Apr 10 '19 at 05:36

0 Answers0