我在ThreadPoolTaskExecutor中具有以下代码。当我一次发送100个请求时,它正在执行所有请求。但我一次只希望5个请求。 如何实现这一目标?
@EnableAsync
@SpringBootApplication
public class GroupDepositsApplication {
@Bean(name = "processExecutor")
public TaskExecutor workExecutor()
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(50);
executor.setMaxPoolSize(Integer.MAX_VALUE);
executor.setQueueCapacity(50);
executor.setThreadNamePrefix("MyExecutor");
executor.initialize();
return executor;
}
public static void main(String[] args) {
SpringApplication.run(DepositApplication.class, args);
}
}
this the method controller will be calling
@Async("processExecutor")
public void processPendingAwardRecords(
List<GroupEntity> pendingRecordsToProcess,
User user) {
// data base operations......
}