Spring ThreadPoolTaskExecutor with fixed delay?

I have a Job which is scheduled to run every hour which uses Spring ThreadPoolTaskExecutor bean to fire simultaneous calls (close to 100 calls every hour) to external API.

@Bean

public TaskExecutor getExecutor() {

ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();

threadPoolTaskExecutor.setCorePoolSize(10);

threadPoolTaskExecutor.setMaxPoolSize(20);

return threadPoolTaskExecutor;

}

Now, the external API has throttled the number of requests and allows one request per 30 secs. I will have to wait 30 secs before making each call.

In this case, I see use of ThreadPoolTaskExecutor is no longer helpful. Will ThreadPoolTaskScheduler with Fixed Delay configuration work?

What is the best way to handle...

Read More »

By: StackOverFlow - Thursday, 8 November

Related Posts