This commit is contained in:
2025-03-08 15:46:24 +08:00
parent 50927481d2
commit c2ebbd71e2
35 changed files with 303 additions and 314 deletions

View File

@@ -0,0 +1,59 @@
package com.ycwl.basic.config;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.*;
public class CachedBodyHttpServletRequest extends HttpServletRequestWrapper {
private final byte[] cachedBody;
public CachedBodyHttpServletRequest(HttpServletRequest request) throws IOException {
super(request);
// 缓存请求体内容
InputStream requestInputStream = request.getInputStream();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int read;
while ((read = requestInputStream.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, read);
}
cachedBody = byteArrayOutputStream.toByteArray();
}
@Override
public ServletInputStream getInputStream() {
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(cachedBody);
return new ServletInputStream() {
@Override
public int read() throws IOException {
return byteArrayInputStream.read();
}
@Override
public boolean isFinished() {
return false;
}
@Override
public boolean isReady() {
return true;
}
@Override
public void setReadListener(ReadListener readListener) {
// 不需要实现
}
};
}
@Override
public BufferedReader getReader() throws IOException {
return new BufferedReader(new InputStreamReader(this.getInputStream()));
}
public byte[] getCachedBody() {
return cachedBody;
}
}

View File

@@ -1,31 +0,0 @@
//package com.ycwl.basic.config;
//
//import org.redisson.Redisson;
//import org.redisson.api.RedissonClient;
//import org.redisson.config.Config;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class RedissonConfig {
//
// @Value("${spring.redis.host}")
// private String host;
// @Value("${spring.redis.port}")
// private String port;
// @Value("${spring.redis.password}")
// private String password;
//
// @Bean
// public RedissonClient getRedisSon() {
// Config config = new Config();
// String address = new StringBuilder("redis://").append(host).append(":").append(port).toString();
// config.useSingleServer().setAddress(address);
// if (null != password && !"".equals(password.trim())) {
// config.useSingleServer().setPassword(password);
// }
// return Redisson.create(config);
// }
//
//}

View File

@@ -12,7 +12,7 @@ public class SchedulerConfig {
@Bean
public ThreadPoolTaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(256);
scheduler.setPoolSize(128);
scheduler.setThreadNamePrefix("Scheduler-");
return scheduler;
}