This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Query is updating the RequestOBject to DB in spring Microservices based application

 
Ranch Hand
Posts: 97
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need some clarifications on the best practises that needs to be followed while updating data into the DB in a spring microservices based webapplication

Scenario

We have a webapplication, in which when the user sends request from the UI, for processing the request, at the backend the request goes to a microservice and we have to update the request and response objects in a particular table in the database. I wanted to know the right approach for updating the data in the databse. Below are my queries.
  • Should we insert the request Object as soon as we receive it in the microservices or
  • Should we process the request and after the processing, once we receive the response, should we do a single insert to the database with both request and response Object to avoid multiple DB calls.


  • Please Advise.
    Any help on this is much appreciated. Thanks in Advance.
     
    Sheriff
    Posts: 24654
    58
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Suppose there's a failure in the microservice and no response object is sent. Do you want the request to go into the DB or not?
     
    Varshini Priya
    Ranch Hand
    Posts: 97
    Eclipse IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi - Yes I want the request object to be available in the DB.  Even if there is any failure of microservice before processing the response.
     
    Paul Clapham
    Sheriff
    Posts: 24654
    58
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Then to me, that is suggestive of how to design your app. As for "best practices"... One "best practice" is to not allow best practices to prevent you from producing a design which does what the specs say.

    Let me ask you a follow-on question, though. If there's a catastrophic failure while your microservice is running and it's unable to update the database with the response object, do you still want to see the request object in the database?
     
    Danger, 10,000 volts, very electic .... tiny ad:
    Java file APIs (DOC, XLS, PDF, and many more)
    https://products.aspose.com/total/java
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!