This week's giveaway is in the Java in General forum.
We're giving away four copies of Java Challengers and have Rafael del Nero on-line!
See this thread for details.
Win a copy of Java Challengers this week in the Java in General 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
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Microservices intra-communication: using REST or Messaging ?

 
Bartender
Posts: 1304
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: 1304
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: 6930
164
  • 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: 1304
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic