I’m trying to exeucte the below code for concurrency but the concurrency threads are never responding back. Please find the below pseudo-code, after creating the 10 parallel threads and the control is going till studentRepo.findStudentsWithPagination method but never responding back and further next code of sending records to kafka is not getting executed, is there any executorservice configuration mistake present? or how to debug this scenario, I’m facing this issue in my production environment.
@Component
public class Test{
@Autowired
private StudentRepo studRepo;
@Autowired
private KafkaProducer kafkaProducer;
@PostConstruct
public void init(){
ExecutorService executor = Executors.newFixedThreadPool(10);
for(int i=1; i <= 10; i++){
final int a=i;
executor.submit(()->{
List<StudentEntity> students = studRepo.findStudentsWithPagination(PageRequest.of(pageNo, 500000));
log.info("result: {}",students );
// do some computing here and send to kafka
kafkaProducer.send(students);
})
}
}
}