How to trigger parallel calls for REST API controller in Spring Boot

Viewed 25

I'm working on a Java Spring project and I have the following controller:

@RestController
class EmployeeController {
    
    //....
    @PostMapping("/employees")
    Employee newEmployee(@RequestBody Employee newEmployee) {
        return repository.save(newEmployee);
    }
    
}

Now I'm working on another Java project where I read (using POI) an Excel file that contains 1000 rows. I want to call my API POST employee in parallel mode. I want to insert 100 rows by 100 rows once instead of looping through my rows and make the calls.

Do you have any suggestions on how I can do this correctly without having performance issues? I plan to use RestTemplate to make my HTTP calls and I read about CompletableFuture to do asynchronous calls. I don't have any idea how I can use this API.

0 Answers
Related