Springboot Multithread Calling Many Services At Same Time

I want to ask for some ideas for my project. I'm calling a web service inside my Springboot project.

It's a web service project. So, my project will take a list of criteria queries from customers and according to these criteria, I will call another external service. It's a kind of gateway project.

Normally, I want to query this external service to give me some data as a list. However, this external service doesn't provide me a list of data. Instead of it, this service provides just one record per call. That's why I have to call this external service for each record and these records can be maybe more than 1000. For that reason, calling this service inside a loop will be a performance problem.

I'm looking at Springboot multithread operation. With ThreadPoolTaskExecutor, we can use many threads to call web services. However, I don't know even it's a good idea or not and how many threads should I execute? And is it good to use these threads as Async?

To give an example, My project will get a list of user's id from outside. And I will need to get details of each user with a user id from another external service. However, this external service doesn't give me a list of users, instead of it, this external service just returns one user according to user id. That's why I need to call the many time's same services with each user id and make some changes to this data. After that response, the details list to who call my gateway project.

I don't have enough multithread experiences that's why I'm asking your opinions to solve this problem.

Best regards.

Read more here: https://stackoverflow.com/questions/64894487/springboot-multithread-calling-many-services-at-same-time

Content Attribution

This content was originally published by tester at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: