简体   繁体   中英

Designing a bulk REST API in Java

I have a problem with my appilication when am perfoming bulk update's and create's.

I have very huge rest pay load which contains 1000 fields and with 10000 update at a time. After submitting the request data will be save in db with jdbc procedure.

Now here we are facing perfomance issue.

i have to design a bulk api to reslve this perfomance issue.

i searched existing bulk api by Sales force and Telerik.But not clear about their implemention.

How do i design a my own bulk REST API in java for bulk update's and create's.

Which design patterns should i take into consideration?

It will be helpful for me, if any body could answer me.

Thanks in advance.

An often used term in REST is "Collection Resource".

Consider a system that stores invoices. The collection resource for them could have the URL

/resources

while a single invoice with ID 123 could have the URL

/resources/123

Adding a new invoice to the collection would be done using

POST /resources
Content-Type: application/json

{
  "customer": "CUS-123",
  "amount": 1.43,
  "paided": false
}

The server would store it and assign an ID to it.

To store more than one invoices in one request, it would make sense to post an array:

POST /invoices
Content-Type: application/json

[
  {
    "customer": "CUS-123",
    "amount": 1.43,
    "paided": false
  },
  {
    "customer": "CUS-456",
    "amount": 42.23,
    "paided": true
  }      
]

It would the responsibiltity of the server to recognize that now there are more than one invoice to store.

One example of such an API is ElasticSearch bulk update support: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

You can take some inspiration there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM