fix:执行引擎

1.从堆栈信息,redis相关类会占用很多内存,且一直在增加。
2.从代码中没有找到使用redis的业务,所以将redis的启动配置、相关接口信息删掉。
hz_1122_temp
李杰应 2024-12-03 15:30:41 +08:00
parent 9b5af12c3a
commit 2a5ed5f6fb
2 changed files with 0 additions and 210 deletions

View File

@ -1,190 +0,0 @@
/*
* Copyright (c) Corporation 2021 . All rights reserved.
*
*/
package net.northking.cctp.se.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import net.northking.cctp.common.cache.EntityNameCache;
import net.northking.cctp.common.cache.EntityNameRedisRepository;
import net.northking.cctp.common.saas.cache.SaaSTenantCache;
import net.northking.cctp.common.saas.cache.StaticTenantCache;
import net.northking.cctp.common.security.authorization.ResourceAuthorityCache;
import net.northking.cctp.common.security.authorization.ResourceAuthorityRedisRepository;
import net.northking.cctp.common.sequence.SequenceDistributedService;
import net.northking.cctp.common.sequence.SequenceNoneStorage;
import net.northking.cctp.common.sequence.SequenceService;
import net.northking.cctp.common.sequence.SequenceStorage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.integration.redis.util.RedisLockRegistry;
/**
*
*
* @author : xiusong.xie
* @version : 1.0
*/
@Configuration
public class CacheConfiguration
{
private static final Logger logger = LoggerFactory.getLogger(CacheConfiguration.class);
/**
* redisTemplate
*
* @return redisTemplate
*/
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory)
{
RedisTemplate<String, Object> template = new RedisTemplate<>();
// 配置连接工厂
template.setConnectionFactory(factory);
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值默认使用JDK的序列化方式
Jackson2JsonRedisSerializer<Object> jsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
ObjectMapper om = new ObjectMapper();
// 指定要序列化的域field,get和set,以及修饰符范围ANY是都有包括private和public
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 指定序列化输入的类型类必须是非final修饰的final修饰的类比如String,Integer等会跑出异常
jsonRedisSerializer.setObjectMapper(om);
// 值采用json序列化
template.setValueSerializer(jsonRedisSerializer);
//使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
// 设置hash key 和value序列化模式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(jsonRedisSerializer);
template.afterPropertiesSet();
logger.info("注册公共组件提示:统一配置 RedisTemplate<String, Object> 已完成。");
return template;
}
/**
* Spring CacheJSON
*
* @return RedisCacheConfiguration
*/
@Bean
public RedisCacheConfiguration redisCacheConfiguration()
{
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值默认使用JDK的序列化方式
Jackson2JsonRedisSerializer<Object> jsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
ObjectMapper om = new ObjectMapper();
// 指定要序列化的域field,get和set,以及修饰符范围ANY是都有包括private和public
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 指定序列化输入的类型类必须是非final修饰的final修饰的类比如String,Integer等会跑出异常
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
// 找不到匹配属性时忽略报错
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// 不包含任何属性的bean也不报错
om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
// JSON序列化忽略空值包含NULL和空字符串
om.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
jsonRedisSerializer.setObjectMapper(om);
logger.info("注册公共组件提示:统一配置 Spring Cache序列化方式JSON。");
return RedisCacheConfiguration.defaultCacheConfig()
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonRedisSerializer));
}
/**
* Redis
*
* @return
*/
@Bean
public RedisLockRegistry redisLockRegistry(RedisConnectionFactory factory)
{
logger.info("注册公共组件提示:统一配置 全局锁(RedisLockRegistry) 已完成。");
return new RedisLockRegistry(factory, "CCTP_LOCK");
}
/**
*
*
* @return
*/
@Bean
@ConditionalOnMissingBean
public ResourceAuthorityCache resourceAuthorityCache(RedisTemplate<String, Object> redisTemplate)
{
logger.info("注册公共组件提示:统一配置 用户权限缓存(ResourceAuthorityCache) 已完成。");
return new ResourceAuthorityRedisRepository(redisTemplate);
}
/**
*
*
* @return
*/
@Bean
@ConditionalOnMissingBean
public EntityNameCache entityNameCache(RedisTemplate<String, Object> redisTemplate)
{
logger.info("注册公共组件提示:统一配置 实体命名缓存(EntityNameCache) 已完成。");
return new EntityNameRedisRepository(redisTemplate);
}
/**
*
*
* @return
*/
@Bean
@ConditionalOnMissingBean
public SaaSTenantCache staticTenantCache()
{
return new StaticTenantCache();
}
/**
*
*
* @return
*/
@Bean
@ConditionalOnMissingBean
public SequenceStorage sequenceStorage()
{
return new SequenceNoneStorage();
}
/**
*
*
* @param factory redis
* @param sequenceStorage
* @return
*/
@Bean
public SequenceService sequenceService(RedisConnectionFactory factory, SequenceStorage sequenceStorage)
{
logger.info("注册公共组件提示:统一配置 分布式序列服务(SequenceService) 已完成。");
return new SequenceDistributedService(factory, sequenceStorage);
}
}

View File

@ -12,7 +12,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
@ -35,10 +34,6 @@ public class LifecycleCtrl
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private RedisTemplate redisTemplate;
/**
*
*
@ -55,21 +50,6 @@ public class LifecycleCtrl
return wrapper;
}
/**
* redisKey
*
* @return
*/
@ApiOperation(value = "获取redis指定Key的数据")
@GetMapping(value = "/getRedisKey/{key}")
public ResultWrapper<Object> getRedisKey(@PathVariable("key") String key)
{
ResultWrapper<Object> wrapper = new ResultWrapper<>();
Object info = redisTemplate.opsForValue().get(key);
wrapper.success(info);
return wrapper;
}
/**
* /
*