• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

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

 
Ranch Hand
Posts: 102
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    Marshal
    Posts: 28303
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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: 102
    Eclipse IDE
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
    Marshal
    Posts: 28303
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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?
     
    Pay attention! Tiny ad!
    Smokeless wood heat with a rocket mass heater
    https://woodheat.net
    reply
      Bookmark Topic Watch Topic
    • New Topic