package com.nokia.domainb;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class DomainBApplication {

    public static void main(String[] args) {
        SpringApplication.run(DomainBApplication.class, args);
    }

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Bean
    public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
        ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
        scheduler.setPoolSize(10);
        scheduler.setWaitForTasksToCompleteOnShutdown(true);
//        scheduler.setThreadNamePrefix("");
//        scheduler.setAwaitTerminationSeconds(60);
//        scheduler.setErrorHandler(e -> log.error(">>> {}", e.getMessage(), e));
        scheduler.initialize();
        return scheduler;
    }
}
