0

First thing first, this question is for Java8.

Having said that, let's go to the problem in hand.

I am new to java and there seems to be so many different ways to accomplish this. However, I am not sure which one is the correct one. Also, limit of concurrent calls also makes it challenging for me to solve.

Can someone please point me to the Java topic which I need to learn?

Thanks for your time. I really appreciate your help.

Tahir Rauf
  • 484
  • 6
  • 16

2 Answers2

1

On top of my head

  • Apache HttpClient
  • Spring-Boot @Async, threadPoolTaskExecutor limit to maxPoolSize = 8

That should do it.

Edited If you do not want to use Spring, you can just use ForkJoinPool with Stream. Check this out -> https://www.baeldung.com/java-8-parallel-streams-custom-threadpool

Chayne P. S.
  • 1,558
  • 12
  • 17
1

IMO, If your project is developed using Spring framework, then I would suggest you to go with WebFlux. It is the implementation of RxJava, a reactive programming approach. The documentation link is here. It includes an HTTP client, which supports non-blocking, called WebClient with which you can make HTTP calls.

Otherwise, CompletableFuture with ExecutorService having customized threadpool configuration depending on your API concurrency. This will be the good option.

the_tech_maddy
  • 575
  • 2
  • 6
  • 21
  • Thanks for the reply. I should have mention this in my question, that using framework is not the option in my case. I am going to look at completableFuture and ExecutorService. If you have some example link handy, it would be of great help. Thanks for your reply. – Tahir Rauf Sep 10 '20 at 05:45
  • `CompletableFuture` is the option that I would chose. – Vishwa Ratna Sep 10 '20 at 05:48
  • You can use Baeldung resource. It has beginner level tutorials – the_tech_maddy Sep 13 '20 at 18:19