添加示例项目中自定义拒绝策略 SPI 实现. (#61)

pull/84/head
chen.ma 3 years ago
parent 6123ca3f3c
commit 2873219ba8

@ -0,0 +1,38 @@
package cn.hippo4j.example.handler;
import cn.hippo4j.starter.spi.CustomRejectedExecutionHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
/**
* .
*
* @author chen.ma
* @date 2022/1/4 22:19
*/
public class ErrorLogRejectedExecutionHandler implements CustomRejectedExecutionHandler {
@Override
public Integer getType() {
return 12;
}
@Override
public RejectedExecutionHandler generateRejected() {
return new CustomErrorLogRejectedExecutionHandler();
}
public static class CustomErrorLogRejectedExecutionHandler implements RejectedExecutionHandler {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
Logger logger = LoggerFactory.getLogger(this.getClass());
logger.error("线程池抛出拒绝策略.");
}
}
}
Loading…
Cancel
Save