1

Here is a different scenario for GET or POST confusion. I am working on a web application built with spring-boot microservice architecture where there is a need of validate and update some bulk data from excel sheet. There can be 500-1000 records in excel sheet with 6 different columns for bulk processing. Once UI submits the excel sheet to server from then the total process is asynchronous. There are microservice to microservice calls which I am getting confused to have GET or POST.

Here is a problem: I have 4 microservices (let's say orchestra-service,A-service,B-service and C-service). OrchestraService creates a DTO list from excel sheet which will be used in further calls. Orchestra calls 'A'. 'A' validates the data with DB and marks success and failure records in DTO list object and returns the list back to orchestra. Again orchestra calls 'B', it does the similar job like 'A' and returns back to orchestra. Now orchestra calls 'C' which will update success records into database, updates the file status on database and also creates a new resultant excel sheet with error messages per row which will be emailed to the user later(small report kind of thing).

In above microservice to microservice calls only C is updating database and creating resource on server. All above calls I used POST method because I need the request body to pass my input list to all services. According to HTTP Standards am I doing right? https://www.rfc-editor.org/rfc/rfc7231#section-4.3.3 Providing a block of data, such as the fields entered into an HTML form, to a data-handling process it should be a POST call.

Please advice me whether:

  1. I should use POST for only 'C' and GET for others or

  2. It should be POST for all as other process involves in data filtering process.

NOTE: service A,B, and C not all services uses all the columns of excel but some of them in combinations. One column having 18 characters long data so I think it can be a problem with GET header limit for bulk operation.

Community
  • 1
  • 1
  • 1
    I believe you’ve answered to your question yourself. As you can only pass limited volume of data with GET request using POST is always safer choice in situation like yours. I’m sure you don’t want to get into the situation when data uploaded with GET would be simply truncated without notice. This topic may provide some additional insight https://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request – Oleksandr Tyshchenko Sep 01 '19 at 19:44

2 Answers2

0

Http Protocol

There is no actual violation on passing information on GET and if that request doesn't mutate between identical requests, then it's fine.

Microservice wise

Now for clarification, are Service A and Service B actually needed ? Aren't they the same Domain as Service C, and can reside inside of him ? It's more then good practice to have a Microservice validate its own domain and return a collection of success and failure with the relevant messages.

Orel Eraki
  • 11,940
  • 3
  • 28
  • 36
  • Yes actually, by existing design 'A' is dealing with some group of db entities and 'B' is dealing with some another group of db entities. If I need to perform all validations in one place then I need to copy all required entity classes into one service. – lightwings Sep 01 '19 at 18:28
  • Will it be OK to copy such classes into one service according to microservice architecture?? – lightwings Sep 01 '19 at 18:29
  • "Will it be OK to copy such classes into one service according to microservice architecture??" --> If they don't have a strong domain meaning : it could be a shared library. But if they represent domain, avoid duplication. – Pierre Sevrain Sep 02 '19 at 15:20
0

I had the similar question few years back and here is the possible solution for the first part of your question.

As mentioned by @Oreal Eraki in his answer, I would also question whether you need services A and B. If its just validation and data transformation it can be done in the same domain where the data is actually stored.

Rishikesh Dhokare
  • 3,559
  • 23
  • 34
  • Yes both services are required you can refer the above comment. Same question, will it be a good idea to copy such domain entities to one service for validations? or is there any other way if an existing design has such problem. – lightwings Sep 01 '19 at 18:36