add: 线程、tomcat监控

This commit is contained in:
2024-01-05 14:09:39 +08:00
parent 62023a452e
commit ee632a69cd
5 changed files with 67 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ package org.nl;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
import com.alicp.jetcache.anno.config.EnableMethodCache;
import org.dromara.dynamictp.core.spring.EnableDynamicTp;
import org.mybatis.spring.annotation.MapperScan;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.boot.SpringApplication;
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@EnableAsync
@RestController
@EnableDynamicTp
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
})

View File

@@ -16,7 +16,12 @@
package org.nl.config.thread;
import org.dromara.dynamictp.core.support.DynamicTp;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@@ -28,16 +33,22 @@ import java.util.concurrent.TimeUnit;
* @author Zheng Jie
* @date 2019年10月31日18:16:47
*/
@Configuration
public class ThreadPoolExecutorUtil {
public static ThreadPoolExecutor getPoll() {
AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
@Autowired
private AsyncTaskProperties asyncTaskProperties;
@Bean
@Primary
@DynamicTp("el-thread")
public ThreadPoolExecutor threadPoolExecutor() {
return new ThreadPoolExecutor(
properties.getCorePoolSize(),
properties.getMaxPoolSize(),
properties.getKeepAliveSeconds(),
asyncTaskProperties.getCorePoolSize(),
asyncTaskProperties.getMaxPoolSize(),
asyncTaskProperties.getKeepAliveSeconds(),
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(properties.getQueueCapacity()),
new ArrayBlockingQueue<>(asyncTaskProperties.getQueueCapacity()),
new TheadFactoryName()
);
}

View File

@@ -16,6 +16,8 @@ import org.nl.system.service.quartz.impl.SysQuartzJobServiceImpl;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import java.util.concurrent.Future;
@@ -35,7 +37,9 @@ public class ExecutionJob extends TLogQuartzJobBean {
/**
* 该处仅供参考
*/
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
@Autowired
@Qualifier("threadPoolExecutor")
private ThreadPoolExecutor EXECUTOR;
@Override
public void executeTask(JobExecutionContext context) throws JobExecutionException {