• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Microservices intra-communication: using REST or Messaging ?

 
Bartender
Posts: 1381
39
IBM DB2 Netbeans IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my humble experience, I've found that microservices intra-communication, in practice, is usually implemented in two different flavours: a) using REST  and b) using asynchronous messaging.
I wonder which is the best approach, but I cannot find an ultimate answer to this dilemma. Reading pros and cons, I'm  starting to think that the best approach is using messaging, mainly because it decouples at the most level microservices. You send a message, some other service will respond. On the other hand, looks like that Spring Boot first choice is to use a REST based approach, just because a number of example I've seen on the web are all about using Eureka (and service discovery),
Feign and so on; nevertheless, I've the feeling that using REST at the very end force you to work synchronously and induces a deeper coupling between services.
So, at the very end, I'm really confused.
What is your opinion about ?
 
Claude Moore
Bartender
Posts: 1381
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After furher investigation, I came to the conclusion that the most likely answer is " use both ", I mean both REST and messaging. I ended with this (mental) schema:
- use REST for synchronous communications: mainly for microservices exposing APIs towards front-ends (aka 'backend for frontend' ms), when they need to exchange information with most inner microservices;
- use messaging (with orchestration / choreography) for all asynchronous interactions.
 
Saloon Keeper
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That sounds about right. Microservices should indeed be "micro" - come quickly to a result, and return it synchronously. If a quick result can't be guaranteed, well - you can still implement it as a microservice (so the client doesn't need to bother with other access methods), but its "result" would be more like "yep, I've queued it, check back later for a result".
 
Claude Moore
Bartender
Posts: 1381
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:That sounds about right. Microservices should indeed be "micro" - come quickly to a result, and return it synchronously. If a quick result can't be guaranteed, well - you can still implement it as a microservice (so the client doesn't need to bother with other access methods), but its "result" would be more like "yep, I've queued it, check back later for a result".



Thanks for your feedback !
The more I study MSA (microservices architecture), the more I believe that the adjective "micro" is greatly misleading. At the very end a Microservices is an independent  business logic unit which must be able to get engaged in really complex scenarios.
Despite the fact a single MS  must be as small as necessary to just "do a single thing well",  interactions between microservices, data exchange and so on is really a though matter.
 
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic