案例专家:es修改索引格式、添加event-stream专属线程池

This commit is contained in:
liu.zixi
2025-10-11 17:33:48 +08:00
parent 0a55fbd08f
commit fa740f8f40
3 changed files with 33 additions and 21 deletions

View File

@@ -1,6 +1,8 @@
package com.xboe.config;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Dispatcher;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -44,4 +46,27 @@ public class ThreadPoolConfig {
executor.getQueueCapacity());
return executor;
}
/**
* event-stream线程池
* @return
*/
@Bean(name = "eventStreamExecutor")
public ThreadPoolTaskExecutor eventStreamExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(10);
executor.setMaxPoolSize(500);
executor.setQueueCapacity(10);
executor.setThreadNamePrefix("event-stream-");
executor.setKeepAliveSeconds(300);
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.initialize();
return executor;
}
@Bean(name = "customDispatcher")
public Dispatcher customDispatcher(@Qualifier("eventStreamExecutor") ThreadPoolTaskExecutor eventStreamExecutor) {
return new Dispatcher(eventStreamExecutor.getThreadPoolExecutor());
}
}