diff --git a/mall-ebtp-cloud-jpa-starter/pom.xml b/mall-ebtp-cloud-jpa-starter/pom.xml index 8594737..e8c50d2 100644 --- a/mall-ebtp-cloud-jpa-starter/pom.xml +++ b/mall-ebtp-cloud-jpa-starter/pom.xml @@ -7,13 +7,13 @@ com.chinaunicom.ebtp mall-ebtp-cloud-parent - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-jpa-starter - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT mall-ebtp-cloud-jpa-starter diff --git a/mall-ebtp-cloud-kafka-starter/pom.xml b/mall-ebtp-cloud-kafka-starter/pom.xml index 79defba..e168560 100644 --- a/mall-ebtp-cloud-kafka-starter/pom.xml +++ b/mall-ebtp-cloud-kafka-starter/pom.xml @@ -8,13 +8,13 @@ com.chinaunicom.ebtp mall-ebtp-cloud-parent - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.ebtp mall-ebtp-cloud-kafka-starter - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT mall-ebtp-cloud-kafka-starter diff --git a/mall-ebtp-cloud-parent/pom.xml b/mall-ebtp-cloud-parent/pom.xml index 8c1b4a7..557ecd2 100644 --- a/mall-ebtp-cloud-parent/pom.xml +++ b/mall-ebtp-cloud-parent/pom.xml @@ -7,12 +7,12 @@ com.chinaunicom.ebtp mall-ebtp-cloud - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-parent - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT pom mall-ebtp-cloud-parent @@ -21,22 +21,22 @@ com.chinaunicom.ebtp mall-ebtp-cloud-jpa-starter - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT com.chinaunicom.ebtp mall-ebtp-cloud-kafka-starter - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT com.chinaunicom.mall.ebtp uboot-common - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT com.chinaunicom.mall.ebtp uboot-core - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT diff --git a/pom.xml b/pom.xml index 15080f3..2b0e133 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.chinaunicom.ebtp mall-ebtp-cloud - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT pom mall-ebtp-cloud diff --git a/uboot-common/pom.xml b/uboot-common/pom.xml index 2ee65bf..1298038 100644 --- a/uboot-common/pom.xml +++ b/uboot-common/pom.xml @@ -6,13 +6,13 @@ com.chinaunicom.ebtp mall-ebtp-cloud-parent - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.mall.ebtp uboot-common - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT uboot-common diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/producer/OperationLogKafkaProducer.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/producer/OperationLogKafkaProducer.java index 3290457..8b2e7c0 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/producer/OperationLogKafkaProducer.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/producer/OperationLogKafkaProducer.java @@ -3,6 +3,7 @@ package com.chinaunicom.mall.ebtp.common.log.producer; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; /** @@ -20,7 +21,7 @@ public class OperationLogKafkaProducer { @Autowired private KafkaTemplate kafkaTemplate; - + @Async public void send(String message) { kafkaTemplate.send(TOPIC, message) .addCallback(success -> { diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/impl/OperationLogServiceImpl.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/impl/OperationLogServiceImpl.java index 7efa03a..973afab 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/impl/OperationLogServiceImpl.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/log/service/impl/OperationLogServiceImpl.java @@ -1,6 +1,7 @@ package com.chinaunicom.mall.ebtp.common.log.service.impl; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.exceptions.ExceptionUtil; import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser; import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService; import com.chinaunicom.mall.ebtp.common.constant.CommonConstants; @@ -12,10 +13,13 @@ import com.chinaunicom.mall.ebtp.common.log.service.OperationLogService; import com.chinaunicom.mall.ebtp.common.util.HttpContextUtils; import com.chinaunicom.mall.ebtp.common.util.JsonUtils; import com.chinaunicom.mall.ebtp.common.util.PropertyUtils; +import lombok.extern.slf4j.Slf4j; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletRequest; import java.util.Optional; @@ -29,6 +33,8 @@ import static com.chinaunicom.mall.ebtp.cloud.security.starter.common.Constants. * @author f */ @Service +@Slf4j +@Transactional(propagation = Propagation.NOT_SUPPORTED) public class OperationLogServiceImpl implements OperationLogService { @Autowired @@ -43,38 +49,42 @@ public class OperationLogServiceImpl implements OperationLogService { @Override public void addOperationLog(OperationLog operationLog) { - if (operationLog.getMethod() == null) { - StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); - for (int i = 1; i < stackTrace.length; i++) { - StackTraceElement element = stackTrace[i]; - if (!element.getClassName().equals(OperationLogServiceImpl.class.getName())) { - operationLog.setPackageName(element.getClassName()); - operationLog.setMethod(element.getMethodName()); - break; + try { + if (operationLog.getMethod() == null) { + StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); + for (int i = 1; i < stackTrace.length; i++) { + StackTraceElement element = stackTrace[i]; + if (!element.getClassName().equals(OperationLogServiceImpl.class.getName())) { + operationLog.setPackageName(element.getClassName()); + operationLog.setMethod(element.getMethodName()); + break; + } } } - } - if (operationLog.getMethod() == null) { - StackTraceElement element = Thread.currentThread().getStackTrace()[1]; - operationLog.setPackageName(element.getClassName()); - operationLog.setMethod(element.getMethodName()); - } - BaseCacheUser user = cacheUserService.getCacheUser(); - if (null != user) { - operationLog.setUser(user.setAuthorityList(null)); - HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); - if (request != null) { - // 提取token头信息 ; - operationLog.setToken(request.getHeader(AUTHORIZATION_HEADER)) - .setUrl(request.getMethod() + "." + request.getRequestURI()); + if (operationLog.getMethod() == null) { + StackTraceElement element = Thread.currentThread().getStackTrace()[1]; + operationLog.setPackageName(element.getClassName()); + operationLog.setMethod(element.getMethodName()); + } + BaseCacheUser user = cacheUserService.getCacheUser(); + if (null != user) { + operationLog.setUser(user.setAuthorityList(null)); + HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); + if (request != null) { + // 提取token头信息 ; + operationLog.setToken(request.getHeader(AUTHORIZATION_HEADER)) + .setUrl(request.getMethod() + "." + request.getRequestURI()); + } } - } - operationLog.setId(PropertyUtils.getSnowflakeId()) - .setTransactionId(Optional.ofNullable(operationLog.getTransactionId()).orElseGet(() -> MDC.get(CommonConstants.TRANSACTION_ID))) - .setServiceName(serviceName); - kafkaProducer.send(JsonUtils.objectToJson(operationLog)); + operationLog.setId(PropertyUtils.getSnowflakeId()) + .setTransactionId(Optional.ofNullable(operationLog.getTransactionId()).orElseGet(() -> MDC.get(CommonConstants.TRANSACTION_ID))) + .setServiceName(serviceName); + kafkaProducer.send(JsonUtils.objectToJson(operationLog)); + } catch (Exception e) { + log.info(ExceptionUtil.stacktraceToString(e)); + } } diff --git a/uboot-common/src/main/resources/configuration/async-pool.properties b/uboot-common/src/main/resources/configuration/async-pool.properties index 9444b83..52b507d 100644 --- a/uboot-common/src/main/resources/configuration/async-pool.properties +++ b/uboot-common/src/main/resources/configuration/async-pool.properties @@ -1,7 +1,7 @@ #spring.task.execution.pool ̳߳ -async.thead.pool.coreSize=200 -async.thead.pool.maxSize=1000 -async.thead.pool.queueCapaciry=100 -async.thead.pool.keepALive=1000 +async.thead.pool.coreSize=50 +async.thead.pool.maxSize=200 +async.thead.pool.queueCapaciry=600 +async.thead.pool.keepALive=60 async.thead.pool.threadNamePrefix=ebtp-thread \ No newline at end of file diff --git a/uboot-core/pom.xml b/uboot-core/pom.xml index 01bd074..0b6ec67 100644 --- a/uboot-core/pom.xml +++ b/uboot-core/pom.xml @@ -6,13 +6,13 @@ com.chinaunicom.ebtp mall-ebtp-cloud-parent - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT ../mall-ebtp-cloud-parent com.chinaunicom.mall.ebtp uboot-core - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT uboot-core @@ -20,7 +20,7 @@ com.chinaunicom.mall.ebtp uboot-common - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT