• 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
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

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.
     
    Marshal
    Posts: 24587
    55
    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
    Marshal
    Posts: 24587
    55
    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?
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!