package com.xiaopeng.map.config;
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
import java.util.concurrent.Executor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
/**
|
* ADC 推送异步线程池配置
|
*/
|
@EnableAsync
|
@Configuration
|
public class AdcPushAsyncConfig {
|
|
@Bean("adcPushExecutor")
|
public Executor adcPushExecutor() {
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
executor.setCorePoolSize(4);
|
executor.setMaxPoolSize(8);
|
executor.setQueueCapacity(100);
|
executor.setThreadNamePrefix("adc-push-");
|
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
executor.initialize();
|
return executor;
|
}
|
|
@Bean
|
public ObjectMapper om() {
|
ObjectMapper objectMapper = new ObjectMapper();
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
objectMapper.registerModule(new JavaTimeModule());
|
return objectMapper;
|
}
|
}
|