dtp-移除hippop4j依赖

This commit is contained in:
2025-08-27 13:44:35 +08:00
parent 75d3bca541
commit 99922e8630
15 changed files with 49 additions and 75 deletions

View File

@@ -63,11 +63,6 @@
<artifactId>accompany-mq-service</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-core</artifactId>
<version>${hippo4j-core.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>

View File

@@ -1,8 +1,5 @@
package com.accompany.business.config;
import cn.hippo4j.core.executor.DynamicThreadPool;
import cn.hippo4j.core.executor.support.ThreadPoolBuilder;
import cn.hippo4j.core.toolkit.ExecutorTraceContextUtil;
import com.accompany.common.aop.ApiRequestLogAspect;
import com.accompany.core.base.SpringContextHolder;
import com.alibaba.fastjson.JSON;
@@ -16,6 +13,7 @@ import org.springframework.context.annotation.Primary;
import org.springframework.core.task.TaskDecorator;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import javax.validation.constraints.NotNull;
import java.util.UUID;
@@ -29,27 +27,47 @@ public class ExecutorConfig implements AsyncConfigurer {
@Bean
@Primary
@DynamicThreadPool
public ThreadPoolExecutor bizExecutor() {
String threadPoolId = "biz-executor";
return ThreadPoolBuilder.builder()
.threadFactory(threadPoolId)
.threadPoolId(threadPoolId)
.taskDecorator(new MDCDecorator())
.dynamicPool()
.build();
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
// 核心线程数
executor.setCorePoolSize(5);
// 最大线程数
executor.setMaxPoolSize(10);
// 队列容量
executor.setQueueCapacity(100);
// 线程空闲时间(秒)
executor.setKeepAliveSeconds(60);
// 线程名称前缀
executor.setThreadNamePrefix(threadPoolId);
executor.setTaskDecorator(new MDCDecorator());
// 设置拒绝策略
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
// 初始化
executor.initialize();
return executor.getThreadPoolExecutor();
}
@Bean("async-executor")
@DynamicThreadPool
public ThreadPoolExecutor asyncExecutor() {
String threadPoolId = "async-executor";
return ThreadPoolBuilder.builder()
.threadFactory(threadPoolId)
.threadPoolId(threadPoolId)
.taskDecorator(new MDCDecorator())
.dynamicPool()
.build();
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
// 核心线程数
executor.setCorePoolSize(5);
// 最大线程数
executor.setMaxPoolSize(10);
// 队列容量
executor.setQueueCapacity(100);
// 线程空闲时间(秒)
executor.setKeepAliveSeconds(60);
// 线程名称前缀
executor.setThreadNamePrefix(threadPoolId);
executor.setTaskDecorator(new MDCDecorator());
// 设置拒绝策略
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
// 初始化
executor.initialize();
return executor.getThreadPoolExecutor();
}
public static class MDCDecorator implements TaskDecorator {
@@ -67,7 +85,6 @@ public class ExecutorConfig implements AsyncConfigurer {
// Right now: @Async thread context !
// Restore the Web thread context's MDC data
MDC.put(ApiRequestLogAspect.TRACE_UUID, traceId);
ExecutorTraceContextUtil.putTimeoutTrace(traceId);
runnable.run();
} finally {
MDC.remove(ApiRequestLogAspect.TRACE_UUID);

View File

@@ -1,6 +1,5 @@
package com.accompany.business.service.lucky.rank;
import cn.hippo4j.common.toolkit.CollectionUtil;
import com.accompany.business.common.constant.RewardTypeEnum;
import com.accompany.business.common.dto.RewardDto;
import com.accompany.business.common.vo.RewardVo;
@@ -12,7 +11,7 @@ import com.accompany.common.constant.Constant;
import com.accompany.common.redis.RedisKey;
import com.accompany.common.status.BusiStatus;
import com.accompany.common.utils.DateTimeUtil;
import com.accompany.common.utils.NumberUtils;
import com.accompany.core.enumeration.I18nAlertEnum;
import com.accompany.core.exception.ServiceException;
import com.accompany.core.service.SysConfService;
import com.accompany.core.util.I18NMessageSourceUtil;
@@ -30,9 +29,6 @@ import org.springframework.util.CollectionUtils;
import java.time.Instant;
import java.util.*;
import static com.accompany.core.enumeration.I18nAlertEnum.LUCKY_24_SEND_WEEK_RANK_REWARD_TIP;
import static com.accompany.core.enumeration.I18nAlertEnum.ROOM_BOSS_MIC_UP_MSG_I18N;
@Slf4j
@Service
public class Lucky24SendWeekRankRewardService {
@@ -62,7 +58,7 @@ public class Lucky24SendWeekRankRewardService {
long rankSize = settlementSizes.stream().mapToLong(Integer::intValue).max().getAsLong();
List<Lucky24WeekRankItemVo> list = rankService.listRankItem(lastWeek, rankSize, partitionId);
if (CollectionUtil.isEmpty(list)){
if (CollectionUtils.isEmpty(list)){
return;
}
@@ -117,7 +113,7 @@ public class Lucky24SendWeekRankRewardService {
}
if (rankIndex <= 3){
String tip = I18NMessageSourceUtil.getMessage(LUCKY_24_SEND_WEEK_RANK_REWARD_TIP, new Object[]{ranking}, partitionId);
String tip = I18NMessageSourceUtil.getMessage(I18nAlertEnum.LUCKY_24_SEND_WEEK_RANK_REWARD_TIP, new Object[]{ranking}, partitionId);
sendSysMsgService.sendPersonTextMsg(uid, tip);
}

View File

@@ -1,6 +1,5 @@
package com.accompany.business.service.lucky.rank;
import cn.hippo4j.common.toolkit.CollectionUtil;
import com.accompany.business.model.Gift;
import com.accompany.business.service.gift.GiftService;
import com.accompany.business.service.level.LevelService;
@@ -22,6 +21,7 @@ import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.DayOfWeek;
@@ -92,7 +92,7 @@ public class Lucky24SendWeekRankService extends AbstractRankService implements I
}
private Lucky24WeekRankItemVo getUserRankItem(Date now, Users me, List<Lucky24WeekRankItemVo> rankItemList) {
if (CollectionUtil.isEmpty(rankItemList)){
if (CollectionUtils.isEmpty(rankItemList)){
UserLevelVo meLevelVo = levelService.getUserLevelVo(me.getUid());
return new Lucky24WeekRankItemVo(me, meLevelVo, 0, 0d);
}
@@ -109,7 +109,7 @@ public class Lucky24SendWeekRankService extends AbstractRankService implements I
RList<Lucky24Record> rList = getRecordList(partitionId);
int size = Math.min(20, rList.size());
List<Lucky24Record> recordList = rList.subList(0, size);
if (CollectionUtil.isEmpty(recordList)){
if (CollectionUtils.isEmpty(recordList)){
return Collections.emptyList();
}
@@ -158,7 +158,7 @@ public class Lucky24SendWeekRankService extends AbstractRankService implements I
public List<Lucky24WeekRankItemVo> listRankItem(Date date, Long size, Integer partitionId){
Set<Map<String, Object>> rankSet = getRank(date, null, 0L, size - 1, partitionId);
if (CollectionUtil.isEmpty(rankSet)){
if (CollectionUtils.isEmpty(rankSet)){
return Collections.emptyList();
}

View File

@@ -1,6 +1,5 @@
package com.accompany.business;
import cn.hippo4j.core.enable.EnableDynamicThreadPool;
import io.micrometer.core.instrument.MeterRegistry;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
@@ -17,7 +16,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
@EnableDynamicThreadPool
@SpringBootApplication
@EnableTransactionManagement
@EnableAspectJAutoProxy(proxyTargetClass = true)

View File

@@ -1,6 +1,5 @@
package com.accompany.business.controller.activity;
import cn.hippo4j.common.toolkit.CollectionUtil;
import com.accompany.business.service.activity.LuckyNumberActService;
import com.accompany.business.vo.activity.*;
import com.accompany.common.annotation.Authorization;
@@ -14,6 +13,7 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@@ -79,7 +79,7 @@ public class LuckyNumberActController {
@Authorization
@PostMapping(value = "/batchInput")
public BusiResult<Void> batchInput(@RequestBody List<Integer> numbers){
if (CollectionUtil.isEmpty(numbers)){
if (CollectionUtils.isEmpty(numbers)){
throw new ServiceException(BusiStatus.PARAMERROR);
}