• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

RESTful API Call Or Database Query - Microservices Best Practice?  RSS feed

Ranch Hand
Posts: 179
Eclipse IDE Hibernate 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?
Posts: 13176
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • 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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!