Win a copy of Head First Android this week in the Android forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Microservices intra-communication: using REST or Messaging ?

 
Bartender
Posts: 1316
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: 1316
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: 7168
165
  • 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: 1316
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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic