• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

RESTful API Call Or Database Query - Microservices Best Practice?

 
Ranch Hand
Posts: 181
13
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I’m developing for a microservice application.  There are several different microservices but all of them use the same database.  I’ve been presented with a user story that requires querying data saved by one microservice (A) and enriching it from another microservice (B).  As I understand it, in a true microservices architecture this should be done by making an API call from B to A using something like a RestTemplate or HttpClient.  But seeing as the tables that contain the information I need are accessible to B from the database, is it a better design decision to simply write a DAO that gets the data I need?
 
Sheriff
Posts: 15782
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Several microservices using the same database is an antipattern.

Also I don't see how you see using a DAO as an alternative to calling the other microservice. Those two are at different levels of abstraction. That's like asking whether you should buy a car with  manual transmission or a rack and pinion.
 
Come have lunch with me Arthur. Adventure will follow. 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
    Bookmark Topic Watch Topic
  • New Topic