Commit e76c561a by ping.wu

Merge branches 'feature/20210615_PrometheusSchedulerCustom_lb' and 'qa' of…

Merge branches 'feature/20210615_PrometheusSchedulerCustom_lb' and 'qa' of http://gitlab.freemud.com/order-group-application/order-group into qa

# Conflicts:
#	order-application-service/src/main/java/cn/freemud/service/impl/OrderServiceImpl.java
#	order-application-service/src/main/java/cn/freemud/service/impl/SellCouponOrderServiceImpl.java
parents 257bdda7 3b65daee
...@@ -3761,7 +3761,7 @@ public class OrderSdkAdapter { ...@@ -3761,7 +3761,7 @@ public class OrderSdkAdapter {
couponRequest.setStation_id("-1"); couponRequest.setStation_id("-1");
couponRequest.setOperator_id("-1"); couponRequest.setOperator_id("-1");
couponRequest.setStore_id(orderBean.getShopId()); couponRequest.setStore_id(orderBean.getShopId());
couponRequest.setMemberId(orderBean.getUserId()); // couponRequest.setMemberId(orderBean.getUserId());
couponRequest.setOpenid(openId); couponRequest.setOpenid(openId);
// 订单号 替换成唯一序号 // 订单号 替换成唯一序号
couponRequest.setTrans_id(orderBean.getOid()); couponRequest.setTrans_id(orderBean.getOid());
......
...@@ -35,6 +35,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; ...@@ -35,6 +35,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
import tk.mybatis.spring.annotation.MapperScan; import tk.mybatis.spring.annotation.MapperScan;
...@@ -58,6 +59,7 @@ import java.util.concurrent.ThreadPoolExecutor; ...@@ -58,6 +59,7 @@ import java.util.concurrent.ThreadPoolExecutor;
"cn.freemud.fuyou" "cn.freemud.fuyou"
}) })
@EnableAutoConfiguration @EnableAutoConfiguration
@EnableScheduling
public class OrderApplication { public class OrderApplication {
private static final String GRAY_VERSION_PROD = "PROD"; //生产版本 private static final String GRAY_VERSION_PROD = "PROD"; //生产版本
......
...@@ -350,6 +350,9 @@ public class OrderServiceImpl implements Orderservice { ...@@ -350,6 +350,9 @@ public class OrderServiceImpl implements Orderservice {
@Autowired @Autowired
private BuyProductOnceManager buyProductOnceManager; private BuyProductOnceManager buyProductOnceManager;
@Autowired
private OrderBusinessService orderBusinessService;
@Override @Override
public BaseResponse checkBeforeCreateOrder(CheckBeforeCreateOrderRequestVo requestVo) { public BaseResponse checkBeforeCreateOrder(CheckBeforeCreateOrderRequestVo requestVo) {
String trackingNo = LogTreadLocal.getTrackingNo(); String trackingNo = LogTreadLocal.getTrackingNo();
...@@ -3117,7 +3120,7 @@ public class OrderServiceImpl implements Orderservice { ...@@ -3117,7 +3120,7 @@ public class OrderServiceImpl implements Orderservice {
// return; // return;
// } // }
// String accessToken = authorizerAppid.getAuthorizerAccessToken(); // String accessToken = authorizerAppid.getAuthorizerAccessToken();
//// String orderId = orderBean.getOid(); // String orderId = orderBean.getOid();
// MpTemplateMsg template = new MpTemplateMsg(); // MpTemplateMsg template = new MpTemplateMsg();
// MpTemplateMsg.TemplateMsgData data = new MpTemplateMsg.TemplateMsgData(); // MpTemplateMsg.TemplateMsgData data = new MpTemplateMsg.TemplateMsgData();
// MpTemplateMsgDataValue first = new MpTemplateMsgDataValue(); // MpTemplateMsgDataValue first = new MpTemplateMsgDataValue();
...@@ -3125,7 +3128,7 @@ public class OrderServiceImpl implements Orderservice { ...@@ -3125,7 +3128,7 @@ public class OrderServiceImpl implements Orderservice {
// MpTemplateMsgDataValue keyword1 = new MpTemplateMsgDataValue(); // MpTemplateMsgDataValue keyword1 = new MpTemplateMsgDataValue();
// keyword1.setValue(orderId); // keyword1.setValue(orderId);
// MpTemplateMsgDataValue keyword2 = new MpTemplateMsgDataValue(); // MpTemplateMsgDataValue keyword2 = new MpTemplateMsgDataValue();
//// Double amount = orderBean.getAmount() / 100.0D; // Double amount = orderBean.getAmount() / 100.0D;
// keyword2.setValue(amount.toString() + " 元"); // keyword2.setValue(amount.toString() + " 元");
// MpTemplateMsgDataValue keyword3 = new MpTemplateMsgDataValue(); // MpTemplateMsgDataValue keyword3 = new MpTemplateMsgDataValue();
// keyword3.setValue(orderBean.getGmtPay() == null ? "" : DateUtil.convert2String(new Date(orderBean.getGmtPay()), "yyyy-MM-dd HH:mm:ss")); // keyword3.setValue(orderBean.getGmtPay() == null ? "" : DateUtil.convert2String(new Date(orderBean.getGmtPay()), "yyyy-MM-dd HH:mm:ss"));
......
package cn.freemud.service.job;
import com.alibaba.druid.pool.DruidDataSource;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author: liubing.
* @date: 2021/6/15 15:37
*/
@Component
public class PrometheusSchedulerCustomJob {
/**
* mq当前空闲(缓存)的事务通道的数量。
* mq当前空闲(高速缓存)的非事务性通道的数量。
* mq同时空闲(缓存)的事务通道的最大数量。
* mq非事务性通道的最大数量同时处于空闲状态(缓存)。
*/
private final AtomicInteger idleChannelsNotTxGauge, idleChannelsTxGauge, idleChannelsTxHighWaterGauge, idleChannelsNotTxHighWaterGauge;
/**
* 当前连接数
* 最大连接池数量
* 最大连接池数量
* 最小连接池数量
*/
private final AtomicInteger activeCountGauge, maxActiveGauge, maxIdleGauge, minIdleGauge;
private final CachingConnectionFactory cachingConnectionFactory;
private final DruidDataSource druidDataSource;
public PrometheusSchedulerCustomJob(MeterRegistry meterRegistry, CachingConnectionFactory cachingConnectionFactory, DruidDataSource druidDataSource) {
this.cachingConnectionFactory = cachingConnectionFactory;
this.druidDataSource = druidDataSource;
idleChannelsNotTxGauge = meterRegistry.gauge("rabbitmq_idle_channels_not_tx", new AtomicInteger(0));
idleChannelsTxGauge = meterRegistry.gauge("rabbitmq_idle_channels_tx", new AtomicInteger(0));
idleChannelsTxHighWaterGauge = meterRegistry.gauge("rabbitmq_idle_channels_tx_high_water", new AtomicInteger(0));
idleChannelsNotTxHighWaterGauge = meterRegistry.gauge("rabbitmq_idle_channels_not_tx_high_water", new AtomicInteger(0));
activeCountGauge = meterRegistry.gauge("db_active_count", new AtomicInteger(0));
maxActiveGauge = meterRegistry.gauge("db_max_active", new AtomicInteger(0));
maxIdleGauge = meterRegistry.gauge("db_max_idle", new AtomicInteger(0));
minIdleGauge = meterRegistry.gauge("db_min_idle", new AtomicInteger(0));
}
@Scheduled(fixedRateString = "15000", initialDelayString = "0")
public void schedulingTask() {
Properties cacheProperties = cachingConnectionFactory.getCacheProperties();
idleChannelsNotTxGauge.set(Integer.parseInt(cacheProperties.getOrDefault("idleChannelsNotTx", 0).toString()));
idleChannelsTxGauge.set(Integer.parseInt(cacheProperties.getOrDefault("idleChannelsTx", 0).toString()));
idleChannelsTxHighWaterGauge.set(Integer.parseInt(cacheProperties.getOrDefault("idleChannelsTxHighWater", 0).toString()));
idleChannelsNotTxHighWaterGauge.set(Integer.parseInt(cacheProperties.getOrDefault("idleChannelsNotTxHighWater", 0).toString()));
activeCountGauge.set(druidDataSource.getActiveCount());
maxActiveGauge.set(druidDataSource.getMaxActive());
maxIdleGauge.set(druidDataSource.getMaxIdle());
minIdleGauge.set(druidDataSource.getMinIdle());
}
}
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<dependency> <dependency>
<groupId>com.freemud.application.service.sdk</groupId> <groupId>com.freemud.application.service.sdk</groupId>
<artifactId>couponcenter-sdk</artifactId> <artifactId>couponcenter-sdk</artifactId>
<version>4.1.1.RELEASE</version> <version>1.9.2.RELEASE</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
......
...@@ -31,6 +31,7 @@ import org.springframework.context.annotation.Bean; ...@@ -31,6 +31,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
import tk.mybatis.spring.annotation.MapperScan; import tk.mybatis.spring.annotation.MapperScan;
...@@ -48,6 +49,7 @@ import tk.mybatis.spring.annotation.MapperScan; ...@@ -48,6 +49,7 @@ import tk.mybatis.spring.annotation.MapperScan;
"com.freemud.api.assortment.datamanager.manager"}) "com.freemud.api.assortment.datamanager.manager"})
@EnableFeignClients @EnableFeignClients
@EnableAsync @EnableAsync
@EnableScheduling
public class ShoppingCartApplication { public class ShoppingCartApplication {
private static final String GRAY_VERSION_PROD = "PROD"; //生产版本 private static final String GRAY_VERSION_PROD = "PROD"; //生产版本
private static final String GRAY_VERSION_GRAY = "GRAY"; //灰度版本 private static final String GRAY_VERSION_GRAY = "GRAY"; //灰度版本
......
package cn.freemud.service.job;
import com.alibaba.druid.pool.DruidDataSource;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author: liubing.
* @date: 2021/6/15 15:37
*/
@Component
public class PrometheusSchedulerCustomJob {
/**
* mq当前空闲(缓存)的事务通道的数量。
* mq当前空闲(高速缓存)的非事务性通道的数量。
* mq同时空闲(缓存)的事务通道的最大数量。
* mq非事务性通道的最大数量同时处于空闲状态(缓存)。
*/
private final AtomicInteger idleChannelsNotTxGauge, idleChannelsTxGauge, idleChannelsTxHighWaterGauge, idleChannelsNotTxHighWaterGauge;
/**
* 当前连接数
* 最大连接池数量
* 最大连接池数量
* 最小连接池数量
*/
private final AtomicInteger activeCountGauge, maxActiveGauge, maxIdleGauge, minIdleGauge;
private final CachingConnectionFactory cachingConnectionFactory;
private final DruidDataSource druidDataSource;
public PrometheusSchedulerCustomJob(MeterRegistry meterRegistry, CachingConnectionFactory cachingConnectionFactory, DruidDataSource druidDataSource) {
this.cachingConnectionFactory = cachingConnectionFactory;
this.druidDataSource = druidDataSource;
idleChannelsNotTxGauge = meterRegistry.gauge("rabbitmq_idle_channels_not_tx", new AtomicInteger(0));
idleChannelsTxGauge = meterRegistry.gauge("rabbitmq_idle_channels_tx", new AtomicInteger(0));
idleChannelsTxHighWaterGauge = meterRegistry.gauge("rabbitmq_idle_channels_tx_high_water", new AtomicInteger(0));
idleChannelsNotTxHighWaterGauge = meterRegistry.gauge("rabbitmq_idle_channels_not_tx_high_water", new AtomicInteger(0));
activeCountGauge = meterRegistry.gauge("db_active_count", new AtomicInteger(0));
maxActiveGauge = meterRegistry.gauge("db_max_active", new AtomicInteger(0));
maxIdleGauge = meterRegistry.gauge("db_max_idle", new AtomicInteger(0));
minIdleGauge = meterRegistry.gauge("db_min_idle", new AtomicInteger(0));
}
@Scheduled(fixedRateString = "15000", initialDelayString = "0")
public void schedulingTask() {
Properties cacheProperties = cachingConnectionFactory.getCacheProperties();
idleChannelsNotTxGauge.set(Integer.parseInt(cacheProperties.getOrDefault("idleChannelsNotTx", 0).toString()));
idleChannelsTxGauge.set(Integer.parseInt(cacheProperties.getOrDefault("idleChannelsTx", 0).toString()));
idleChannelsTxHighWaterGauge.set(Integer.parseInt(cacheProperties.getOrDefault("idleChannelsTxHighWater", 0).toString()));
idleChannelsNotTxHighWaterGauge.set(Integer.parseInt(cacheProperties.getOrDefault("idleChannelsNotTxHighWater", 0).toString()));
activeCountGauge.set(druidDataSource.getActiveCount());
maxActiveGauge.set(druidDataSource.getMaxActive());
maxIdleGauge.set(druidDataSource.getMaxIdle());
minIdleGauge.set(druidDataSource.getMinIdle());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment