feat(sj_1.5.0): 增加查询日志的异步线程池
This commit is contained in:
parent
2b057831d8
commit
284c854a5d
@ -0,0 +1,25 @@
|
|||||||
|
package com.aizuda.snailjob.server.web.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
|
||||||
|
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@EnableAsync
|
||||||
|
@Configuration
|
||||||
|
public class ThreadPoolConfig {
|
||||||
|
@Bean("logQueryExecutor")
|
||||||
|
public ThreadPoolExecutor logQueryExecutor() {
|
||||||
|
return new ThreadPoolExecutor(
|
||||||
|
3,
|
||||||
|
16,
|
||||||
|
30,
|
||||||
|
TimeUnit.SECONDS,
|
||||||
|
new LinkedBlockingQueue<>(1000),
|
||||||
|
new CustomizableThreadFactory("snail-job-log-query-"));
|
||||||
|
}
|
||||||
|
}
|
@ -5,17 +5,12 @@ import com.aizuda.snailjob.server.common.enums.WebSocketSceneEnum;
|
|||||||
import com.aizuda.snailjob.server.common.vo.JobLogQueryVO;
|
import com.aizuda.snailjob.server.common.vo.JobLogQueryVO;
|
||||||
import com.aizuda.snailjob.server.web.model.event.WsRequestEvent;
|
import com.aizuda.snailjob.server.web.model.event.WsRequestEvent;
|
||||||
import com.aizuda.snailjob.server.web.service.JobLogService;
|
import com.aizuda.snailjob.server.web.service.JobLogService;
|
||||||
import jakarta.websocket.Session;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static com.aizuda.snailjob.server.web.socket.LogServer.USER_SESSION;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:srzou
|
* @Author:srzou
|
||||||
* @Package:com.aizuda.snailjob.server.web.listener
|
* @Package:com.aizuda.snailjob.server.web.listener
|
||||||
@ -30,7 +25,7 @@ import static com.aizuda.snailjob.server.web.socket.LogServer.USER_SESSION;
|
|||||||
public class WsRequestListener {
|
public class WsRequestListener {
|
||||||
private final JobLogService jobLogService;
|
private final JobLogService jobLogService;
|
||||||
|
|
||||||
@Async
|
@Async("logQueryExecutor")
|
||||||
@EventListener(classes = WsRequestEvent.class)
|
@EventListener(classes = WsRequestEvent.class)
|
||||||
public void getJobLogs(WsRequestEvent requestVO) {
|
public void getJobLogs(WsRequestEvent requestVO) {
|
||||||
if (!WebSocketSceneEnum.JOB_LOG_SCENE.equals(requestVO.getSceneEnum())) {
|
if (!WebSocketSceneEnum.JOB_LOG_SCENE.equals(requestVO.getSceneEnum())) {
|
||||||
|
Loading…
Reference in New Issue
Block a user