REQ-3284: 监控查询数量
This commit is contained in:
parent
fd255f6788
commit
034825d0ec
@ -21,6 +21,10 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.axzo</groupId>
|
||||
<artifactId>riven-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.taobao.arthas</groupId>
|
||||
<artifactId>arthas-spring-boot-starter</artifactId>
|
||||
|
||||
@ -80,7 +80,7 @@ public class PushYouMengMessageHandler implements EventHandler, InitializingBean
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event, EventConsumer.Context context) {
|
||||
if (cfg.getPushChannel() != PushChannel.YOU_MENG) return;
|
||||
if (!cfg.isPushChannelEnabled(PushChannel.YOU_MENG)) return;
|
||||
log.info("begin push-handler rocketmq event: {}", event);
|
||||
MessageHistoryUpdatedPayload payload = event.normalizedData(MessageHistoryUpdatedPayload.class);
|
||||
if (Objects.isNull(payload) || StringUtils.isBlank(payload.getNewMessageHistory().getBizId())) {
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package cn.axzo.msg.center.inside.notices.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@RefreshScope
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "diagnosis")
|
||||
public class DiagnosisProps implements EnvironmentAware {
|
||||
|
||||
private Environment environment;
|
||||
private int sqlResultCountWarningThreshold = 5;
|
||||
private boolean enableResultCountWarning = true;
|
||||
|
||||
public String getActiveProfile() {
|
||||
String[] profiles = environment.getActiveProfiles();
|
||||
return profiles.length > 0 ? profiles[0] : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,6 +7,7 @@ import cn.axzo.msg.center.nimpush.PushChannel;
|
||||
import cn.axzo.msg.center.service.enums.AppTerminalTypeEnum;
|
||||
import cn.axzo.msg.center.service.template.response.MessageDetailStyle;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@ -168,10 +169,14 @@ public class PendingMessageBizConfig {
|
||||
* 推送渠道
|
||||
*/
|
||||
@Getter
|
||||
private PushChannel pushChannel = PushChannel.NIM;
|
||||
private Set<PushChannel> pushChannels = Sets.newHashSet(PushChannel.NIM, PushChannel.YOU_MENG);
|
||||
|
||||
@Getter
|
||||
private int todoTitleSearchMaxSize = 5000;
|
||||
private int todoTitleSearchMaxSize = 0;
|
||||
|
||||
public boolean isPushChannelEnabled(PushChannel channel) {
|
||||
return pushChannels != null && pushChannels.contains(channel);
|
||||
}
|
||||
|
||||
public boolean determineOldMsgStatCacheOn() {
|
||||
return isOldMsgStatCacheOn();
|
||||
|
||||
@ -7,8 +7,8 @@ import cn.axzo.msg.center.domain.entity.TodoBusiness;
|
||||
import cn.axzo.msg.center.inside.notices.config.PendingMessageBizConfig;
|
||||
import cn.axzo.msg.center.message.domain.dto.TemplateModelV3;
|
||||
import cn.axzo.msg.center.message.service.impl.v3.AppLink;
|
||||
import cn.axzo.msg.center.message.service.impl.v3.NativeAppLinkUrlConfigVisitor;
|
||||
import cn.axzo.msg.center.message.service.impl.v3.ModelV3Parser;
|
||||
import cn.axzo.msg.center.message.service.impl.v3.NativeAppLinkUrlConfigVisitor;
|
||||
import cn.axzo.msg.center.message.service.todo.manage.TodoExt;
|
||||
import cn.axzo.msg.center.message.service.youmeng.YoumengPush;
|
||||
import cn.axzo.msg.center.message.service.youmeng.YoumengTemplateClient;
|
||||
@ -45,7 +45,7 @@ class TodoPushSender implements ApplicationListener<NewTodoEvent> {
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(@NotNull NewTodoEvent event) {
|
||||
if (cfg.getPushChannel() != PushChannel.YOU_MENG) return;
|
||||
if (!cfg.isPushChannelEnabled(PushChannel.YOU_MENG)) return;
|
||||
log.info("Prepare sending todo push. event={}", event);
|
||||
ArrayList<YoumengPush> pushes = new ArrayList<>();
|
||||
for (Todo todo : event.getTodos()) {
|
||||
|
||||
@ -49,7 +49,7 @@ public class TodoPushSenderV3 implements ApplicationListener<NewTodoEvent> {
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(NewTodoEvent event) {
|
||||
if (cfg.getPushChannel() != PushChannel.NIM) return;
|
||||
if (!cfg.isPushChannelEnabled(PushChannel.NIM)) return;
|
||||
List<PushTerminalEnum> pushTerminalEnums = event
|
||||
.getTemplateModel().getTemplate().determinePushTerminals();
|
||||
List<AppTypeEnum> appTypes = terminalAppMapping.toImTypes(pushTerminalEnums);
|
||||
|
||||
@ -18,7 +18,7 @@ import java.sql.Statement;
|
||||
* @author yanglin
|
||||
*/
|
||||
@Slf4j
|
||||
class SQLAccessor {
|
||||
public class SQLAccessor {
|
||||
|
||||
/**
|
||||
* exception free
|
||||
@ -62,7 +62,7 @@ class SQLAccessor {
|
||||
return ((ClientPreparedStatement) stmt).asSql();
|
||||
}
|
||||
|
||||
private static Statement getStmtFromProxy(ProxyStatement proxy) {
|
||||
public static Statement getStmtFromProxy(ProxyStatement proxy) {
|
||||
Field delegateField = ReflectionUtils.findField(proxy.getClass(), "delegate");
|
||||
if (delegateField == null) return null;
|
||||
delegateField.setAccessible(true);
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package cn.axzo.msg.center.message.service.todo.mybatis;
|
||||
|
||||
import cn.axzo.msg.center.inside.notices.config.DiagnosisProps;
|
||||
import cn.axzo.msg.center.inside.notices.config.PendingMessageBizConfig;
|
||||
import cn.axzo.msg.center.message.service.todo.mybatis.resultcount.ResultCountInterceptor;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@ -17,6 +20,12 @@ public class SqlInterceptorConfig {
|
||||
return new ReplaceInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
ResultCountInterceptor resultCountInterceptor(DiagnosisProps props,
|
||||
ListableBeanFactory beanFactory) {
|
||||
return new ResultCountInterceptor(props, beanFactory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
CollectSQLInterceptor sqlCollectInterceptor() {
|
||||
return new CollectSQLInterceptor();
|
||||
|
||||
@ -0,0 +1,821 @@
|
||||
package cn.axzo.msg.center.message.service.todo.mybatis.resultcount;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URL;
|
||||
import java.sql.Array;
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
import java.sql.Date;
|
||||
import java.sql.NClob;
|
||||
import java.sql.Ref;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.RowId;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLType;
|
||||
import java.sql.SQLWarning;
|
||||
import java.sql.SQLXML;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
class ProxyResultSet implements ResultSet {
|
||||
|
||||
private final ProxyStatement statement;
|
||||
private final ResultSet delegate;
|
||||
|
||||
@Override public boolean next() throws SQLException {
|
||||
boolean moved = delegate.next();
|
||||
if (moved)
|
||||
statement.rowAdvanced();
|
||||
return moved;
|
||||
}
|
||||
|
||||
@Override public void close() throws SQLException {
|
||||
delegate.close();
|
||||
}
|
||||
|
||||
@Override public boolean wasNull() throws SQLException {
|
||||
return delegate.wasNull();
|
||||
}
|
||||
|
||||
@Override public String getString(int columnIndex) throws SQLException {
|
||||
return delegate.getString(columnIndex);
|
||||
}
|
||||
|
||||
@Override public boolean getBoolean(int columnIndex) throws SQLException {
|
||||
return delegate.getBoolean(columnIndex);
|
||||
}
|
||||
|
||||
@Override public byte getByte(int columnIndex) throws SQLException {
|
||||
return delegate.getByte(columnIndex);
|
||||
}
|
||||
|
||||
@Override public short getShort(int columnIndex) throws SQLException {
|
||||
return delegate.getShort(columnIndex);
|
||||
}
|
||||
|
||||
@Override public int getInt(int columnIndex) throws SQLException {
|
||||
return delegate.getInt(columnIndex);
|
||||
}
|
||||
|
||||
@Override public long getLong(int columnIndex) throws SQLException {
|
||||
return delegate.getLong(columnIndex);
|
||||
}
|
||||
|
||||
@Override public float getFloat(int columnIndex) throws SQLException {
|
||||
return delegate.getFloat(columnIndex);
|
||||
}
|
||||
|
||||
@Override public double getDouble(int columnIndex) throws SQLException {
|
||||
return delegate.getDouble(columnIndex);
|
||||
}
|
||||
|
||||
@Deprecated @Override public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
|
||||
return delegate.getBigDecimal(columnIndex, scale);
|
||||
}
|
||||
|
||||
@Override public byte[] getBytes(int columnIndex) throws SQLException {
|
||||
return delegate.getBytes(columnIndex);
|
||||
}
|
||||
|
||||
@Override public Date getDate(int columnIndex) throws SQLException {
|
||||
return delegate.getDate(columnIndex);
|
||||
}
|
||||
|
||||
@Override public Time getTime(int columnIndex) throws SQLException {
|
||||
return delegate.getTime(columnIndex);
|
||||
}
|
||||
|
||||
@Override public Timestamp getTimestamp(int columnIndex) throws SQLException {
|
||||
return delegate.getTimestamp(columnIndex);
|
||||
}
|
||||
|
||||
@Override public InputStream getAsciiStream(int columnIndex) throws SQLException {
|
||||
return delegate.getAsciiStream(columnIndex);
|
||||
}
|
||||
|
||||
@Deprecated @Override public InputStream getUnicodeStream(int columnIndex) throws SQLException {
|
||||
return delegate.getUnicodeStream(columnIndex);
|
||||
}
|
||||
|
||||
@Override public InputStream getBinaryStream(int columnIndex) throws SQLException {
|
||||
return delegate.getBinaryStream(columnIndex);
|
||||
}
|
||||
|
||||
@Override public String getString(String columnLabel) throws SQLException {
|
||||
return delegate.getString(columnLabel);
|
||||
}
|
||||
|
||||
@Override public boolean getBoolean(String columnLabel) throws SQLException {
|
||||
return delegate.getBoolean(columnLabel);
|
||||
}
|
||||
|
||||
@Override public byte getByte(String columnLabel) throws SQLException {
|
||||
return delegate.getByte(columnLabel);
|
||||
}
|
||||
|
||||
@Override public short getShort(String columnLabel) throws SQLException {
|
||||
return delegate.getShort(columnLabel);
|
||||
}
|
||||
|
||||
@Override public int getInt(String columnLabel) throws SQLException {
|
||||
return delegate.getInt(columnLabel);
|
||||
}
|
||||
|
||||
@Override public long getLong(String columnLabel) throws SQLException {
|
||||
return delegate.getLong(columnLabel);
|
||||
}
|
||||
|
||||
@Override public float getFloat(String columnLabel) throws SQLException {
|
||||
return delegate.getFloat(columnLabel);
|
||||
}
|
||||
|
||||
@Override public double getDouble(String columnLabel) throws SQLException {
|
||||
return delegate.getDouble(columnLabel);
|
||||
}
|
||||
|
||||
@Deprecated @Override public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
|
||||
return delegate.getBigDecimal(columnLabel, scale);
|
||||
}
|
||||
|
||||
@Override public byte[] getBytes(String columnLabel) throws SQLException {
|
||||
return delegate.getBytes(columnLabel);
|
||||
}
|
||||
|
||||
@Override public Date getDate(String columnLabel) throws SQLException {
|
||||
return delegate.getDate(columnLabel);
|
||||
}
|
||||
|
||||
@Override public Time getTime(String columnLabel) throws SQLException {
|
||||
return delegate.getTime(columnLabel);
|
||||
}
|
||||
|
||||
@Override public Timestamp getTimestamp(String columnLabel) throws SQLException {
|
||||
return delegate.getTimestamp(columnLabel);
|
||||
}
|
||||
|
||||
@Override public InputStream getAsciiStream(String columnLabel) throws SQLException {
|
||||
return delegate.getAsciiStream(columnLabel);
|
||||
}
|
||||
|
||||
@Deprecated @Override public InputStream getUnicodeStream(String columnLabel) throws SQLException {
|
||||
return delegate.getUnicodeStream(columnLabel);
|
||||
}
|
||||
|
||||
@Override public InputStream getBinaryStream(String columnLabel) throws SQLException {
|
||||
return delegate.getBinaryStream(columnLabel);
|
||||
}
|
||||
|
||||
@Override public SQLWarning getWarnings() throws SQLException {
|
||||
return delegate.getWarnings();
|
||||
}
|
||||
|
||||
@Override public void clearWarnings() throws SQLException {
|
||||
delegate.clearWarnings();
|
||||
}
|
||||
|
||||
@Override public String getCursorName() throws SQLException {
|
||||
return delegate.getCursorName();
|
||||
}
|
||||
|
||||
@Override public ResultSetMetaData getMetaData() throws SQLException {
|
||||
return delegate.getMetaData();
|
||||
}
|
||||
|
||||
@Override public Object getObject(int columnIndex) throws SQLException {
|
||||
return delegate.getObject(columnIndex);
|
||||
}
|
||||
|
||||
@Override public Object getObject(String columnLabel) throws SQLException {
|
||||
return delegate.getObject(columnLabel);
|
||||
}
|
||||
|
||||
@Override public int findColumn(String columnLabel) throws SQLException {
|
||||
return delegate.findColumn(columnLabel);
|
||||
}
|
||||
|
||||
@Override public Reader getCharacterStream(int columnIndex) throws SQLException {
|
||||
return delegate.getCharacterStream(columnIndex);
|
||||
}
|
||||
|
||||
@Override public Reader getCharacterStream(String columnLabel) throws SQLException {
|
||||
return delegate.getCharacterStream(columnLabel);
|
||||
}
|
||||
|
||||
@Override public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
|
||||
return delegate.getBigDecimal(columnIndex);
|
||||
}
|
||||
|
||||
@Override public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
|
||||
return delegate.getBigDecimal(columnLabel);
|
||||
}
|
||||
|
||||
@Override public boolean isBeforeFirst() throws SQLException {
|
||||
return delegate.isBeforeFirst();
|
||||
}
|
||||
|
||||
@Override public boolean isAfterLast() throws SQLException {
|
||||
return delegate.isAfterLast();
|
||||
}
|
||||
|
||||
@Override public boolean isFirst() throws SQLException {
|
||||
return delegate.isFirst();
|
||||
}
|
||||
|
||||
@Override public boolean isLast() throws SQLException {
|
||||
return delegate.isLast();
|
||||
}
|
||||
|
||||
@Override public void beforeFirst() throws SQLException {
|
||||
delegate.beforeFirst();
|
||||
}
|
||||
|
||||
@Override public void afterLast() throws SQLException {
|
||||
delegate.afterLast();
|
||||
}
|
||||
|
||||
@Override public boolean first() throws SQLException {
|
||||
return delegate.first();
|
||||
}
|
||||
|
||||
@Override public boolean last() throws SQLException {
|
||||
return delegate.last();
|
||||
}
|
||||
|
||||
@Override public int getRow() throws SQLException {
|
||||
return delegate.getRow();
|
||||
}
|
||||
|
||||
@Override public boolean absolute(int row) throws SQLException {
|
||||
return delegate.absolute(row);
|
||||
}
|
||||
|
||||
@Override public boolean relative(int rows) throws SQLException {
|
||||
return delegate.relative(rows);
|
||||
}
|
||||
|
||||
@Override public boolean previous() throws SQLException {
|
||||
return delegate.previous();
|
||||
}
|
||||
|
||||
@Override public void setFetchDirection(int direction) throws SQLException {
|
||||
delegate.setFetchDirection(direction);
|
||||
}
|
||||
|
||||
@Override public int getFetchDirection() throws SQLException {
|
||||
return delegate.getFetchDirection();
|
||||
}
|
||||
|
||||
@Override public void setFetchSize(int rows) throws SQLException {
|
||||
delegate.setFetchSize(rows);
|
||||
}
|
||||
|
||||
@Override public int getFetchSize() throws SQLException {
|
||||
return delegate.getFetchSize();
|
||||
}
|
||||
|
||||
@Override public int getType() throws SQLException {
|
||||
return delegate.getType();
|
||||
}
|
||||
|
||||
@Override public int getConcurrency() throws SQLException {
|
||||
return delegate.getConcurrency();
|
||||
}
|
||||
|
||||
@Override public boolean rowUpdated() throws SQLException {
|
||||
return delegate.rowUpdated();
|
||||
}
|
||||
|
||||
@Override public boolean rowInserted() throws SQLException {
|
||||
return delegate.rowInserted();
|
||||
}
|
||||
|
||||
@Override public boolean rowDeleted() throws SQLException {
|
||||
return delegate.rowDeleted();
|
||||
}
|
||||
|
||||
@Override public void updateNull(int columnIndex) throws SQLException {
|
||||
delegate.updateNull(columnIndex);
|
||||
}
|
||||
|
||||
@Override public void updateBoolean(int columnIndex, boolean x) throws SQLException {
|
||||
delegate.updateBoolean(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateByte(int columnIndex, byte x) throws SQLException {
|
||||
delegate.updateByte(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateShort(int columnIndex, short x) throws SQLException {
|
||||
delegate.updateShort(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateInt(int columnIndex, int x) throws SQLException {
|
||||
delegate.updateInt(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateLong(int columnIndex, long x) throws SQLException {
|
||||
delegate.updateLong(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateFloat(int columnIndex, float x) throws SQLException {
|
||||
delegate.updateFloat(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateDouble(int columnIndex, double x) throws SQLException {
|
||||
delegate.updateDouble(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
|
||||
delegate.updateBigDecimal(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateString(int columnIndex, String x) throws SQLException {
|
||||
delegate.updateString(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateBytes(int columnIndex, byte[] x) throws SQLException {
|
||||
delegate.updateBytes(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateDate(int columnIndex, Date x) throws SQLException {
|
||||
delegate.updateDate(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateTime(int columnIndex, Time x) throws SQLException {
|
||||
delegate.updateTime(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
|
||||
delegate.updateTimestamp(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
|
||||
delegate.updateAsciiStream(columnIndex, x, length);
|
||||
}
|
||||
|
||||
@Override public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
|
||||
delegate.updateBinaryStream(columnIndex, x, length);
|
||||
}
|
||||
|
||||
@Override public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
|
||||
delegate.updateCharacterStream(columnIndex, x, length);
|
||||
}
|
||||
|
||||
@Override public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
|
||||
delegate.updateObject(columnIndex, x, scaleOrLength);
|
||||
}
|
||||
|
||||
@Override public void updateObject(int columnIndex, Object x) throws SQLException {
|
||||
delegate.updateObject(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateNull(String columnLabel) throws SQLException {
|
||||
delegate.updateNull(columnLabel);
|
||||
}
|
||||
|
||||
@Override public void updateBoolean(String columnLabel, boolean x) throws SQLException {
|
||||
delegate.updateBoolean(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateByte(String columnLabel, byte x) throws SQLException {
|
||||
delegate.updateByte(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateShort(String columnLabel, short x) throws SQLException {
|
||||
delegate.updateShort(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateInt(String columnLabel, int x) throws SQLException {
|
||||
delegate.updateInt(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateLong(String columnLabel, long x) throws SQLException {
|
||||
delegate.updateLong(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateFloat(String columnLabel, float x) throws SQLException {
|
||||
delegate.updateFloat(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateDouble(String columnLabel, double x) throws SQLException {
|
||||
delegate.updateDouble(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
|
||||
delegate.updateBigDecimal(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateString(String columnLabel, String x) throws SQLException {
|
||||
delegate.updateString(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateBytes(String columnLabel, byte[] x) throws SQLException {
|
||||
delegate.updateBytes(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateDate(String columnLabel, Date x) throws SQLException {
|
||||
delegate.updateDate(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateTime(String columnLabel, Time x) throws SQLException {
|
||||
delegate.updateTime(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
|
||||
delegate.updateTimestamp(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
|
||||
delegate.updateAsciiStream(columnLabel, x, length);
|
||||
}
|
||||
|
||||
@Override public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
|
||||
delegate.updateBinaryStream(columnLabel, x, length);
|
||||
}
|
||||
|
||||
@Override public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
|
||||
delegate.updateCharacterStream(columnLabel, reader, length);
|
||||
}
|
||||
|
||||
@Override public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
|
||||
delegate.updateObject(columnLabel, x, scaleOrLength);
|
||||
}
|
||||
|
||||
@Override public void updateObject(String columnLabel, Object x) throws SQLException {
|
||||
delegate.updateObject(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void insertRow() throws SQLException {
|
||||
delegate.insertRow();
|
||||
}
|
||||
|
||||
@Override public void updateRow() throws SQLException {
|
||||
delegate.updateRow();
|
||||
}
|
||||
|
||||
@Override public void deleteRow() throws SQLException {
|
||||
delegate.deleteRow();
|
||||
}
|
||||
|
||||
@Override public void refreshRow() throws SQLException {
|
||||
delegate.refreshRow();
|
||||
}
|
||||
|
||||
@Override public void cancelRowUpdates() throws SQLException {
|
||||
delegate.cancelRowUpdates();
|
||||
}
|
||||
|
||||
@Override public void moveToInsertRow() throws SQLException {
|
||||
delegate.moveToInsertRow();
|
||||
}
|
||||
|
||||
@Override public void moveToCurrentRow() throws SQLException {
|
||||
delegate.moveToCurrentRow();
|
||||
}
|
||||
|
||||
@Override public Statement getStatement() throws SQLException {
|
||||
return delegate.getStatement();
|
||||
}
|
||||
|
||||
@Override public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
|
||||
return delegate.getObject(columnIndex, map);
|
||||
}
|
||||
|
||||
@Override public Ref getRef(int columnIndex) throws SQLException {
|
||||
return delegate.getRef(columnIndex);
|
||||
}
|
||||
|
||||
@Override public Blob getBlob(int columnIndex) throws SQLException {
|
||||
return delegate.getBlob(columnIndex);
|
||||
}
|
||||
|
||||
@Override public Clob getClob(int columnIndex) throws SQLException {
|
||||
return delegate.getClob(columnIndex);
|
||||
}
|
||||
|
||||
@Override public Array getArray(int columnIndex) throws SQLException {
|
||||
return delegate.getArray(columnIndex);
|
||||
}
|
||||
|
||||
@Override public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
|
||||
return delegate.getObject(columnLabel, map);
|
||||
}
|
||||
|
||||
@Override public Ref getRef(String columnLabel) throws SQLException {
|
||||
return delegate.getRef(columnLabel);
|
||||
}
|
||||
|
||||
@Override public Blob getBlob(String columnLabel) throws SQLException {
|
||||
return delegate.getBlob(columnLabel);
|
||||
}
|
||||
|
||||
@Override public Clob getClob(String columnLabel) throws SQLException {
|
||||
return delegate.getClob(columnLabel);
|
||||
}
|
||||
|
||||
@Override public Array getArray(String columnLabel) throws SQLException {
|
||||
return delegate.getArray(columnLabel);
|
||||
}
|
||||
|
||||
@Override public Date getDate(int columnIndex, Calendar cal) throws SQLException {
|
||||
return delegate.getDate(columnIndex, cal);
|
||||
}
|
||||
|
||||
@Override public Date getDate(String columnLabel, Calendar cal) throws SQLException {
|
||||
return delegate.getDate(columnLabel, cal);
|
||||
}
|
||||
|
||||
@Override public Time getTime(int columnIndex, Calendar cal) throws SQLException {
|
||||
return delegate.getTime(columnIndex, cal);
|
||||
}
|
||||
|
||||
@Override public Time getTime(String columnLabel, Calendar cal) throws SQLException {
|
||||
return delegate.getTime(columnLabel, cal);
|
||||
}
|
||||
|
||||
@Override public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
|
||||
return delegate.getTimestamp(columnIndex, cal);
|
||||
}
|
||||
|
||||
@Override public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
|
||||
return delegate.getTimestamp(columnLabel, cal);
|
||||
}
|
||||
|
||||
@Override public URL getURL(int columnIndex) throws SQLException {
|
||||
return delegate.getURL(columnIndex);
|
||||
}
|
||||
|
||||
@Override public URL getURL(String columnLabel) throws SQLException {
|
||||
return delegate.getURL(columnLabel);
|
||||
}
|
||||
|
||||
@Override public void updateRef(int columnIndex, Ref x) throws SQLException {
|
||||
delegate.updateRef(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateRef(String columnLabel, Ref x) throws SQLException {
|
||||
delegate.updateRef(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateBlob(int columnIndex, Blob x) throws SQLException {
|
||||
delegate.updateBlob(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateBlob(String columnLabel, Blob x) throws SQLException {
|
||||
delegate.updateBlob(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateClob(int columnIndex, Clob x) throws SQLException {
|
||||
delegate.updateClob(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateClob(String columnLabel, Clob x) throws SQLException {
|
||||
delegate.updateClob(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateArray(int columnIndex, Array x) throws SQLException {
|
||||
delegate.updateArray(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateArray(String columnLabel, Array x) throws SQLException {
|
||||
delegate.updateArray(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public RowId getRowId(int columnIndex) throws SQLException {
|
||||
return delegate.getRowId(columnIndex);
|
||||
}
|
||||
|
||||
@Override public RowId getRowId(String columnLabel) throws SQLException {
|
||||
return delegate.getRowId(columnLabel);
|
||||
}
|
||||
|
||||
@Override public void updateRowId(int columnIndex, RowId x) throws SQLException {
|
||||
delegate.updateRowId(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateRowId(String columnLabel, RowId x) throws SQLException {
|
||||
delegate.updateRowId(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public int getHoldability() throws SQLException {
|
||||
return delegate.getHoldability();
|
||||
}
|
||||
|
||||
@Override public boolean isClosed() throws SQLException {
|
||||
return delegate.isClosed();
|
||||
}
|
||||
|
||||
@Override public void updateNString(int columnIndex, String nString) throws SQLException {
|
||||
delegate.updateNString(columnIndex, nString);
|
||||
}
|
||||
|
||||
@Override public void updateNString(String columnLabel, String nString) throws SQLException {
|
||||
delegate.updateNString(columnLabel, nString);
|
||||
}
|
||||
|
||||
@Override public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
|
||||
delegate.updateNClob(columnIndex, nClob);
|
||||
}
|
||||
|
||||
@Override public void updateNClob(String columnLabel, NClob nClob) throws SQLException {
|
||||
delegate.updateNClob(columnLabel, nClob);
|
||||
}
|
||||
|
||||
@Override public NClob getNClob(int columnIndex) throws SQLException {
|
||||
return delegate.getNClob(columnIndex);
|
||||
}
|
||||
|
||||
@Override public NClob getNClob(String columnLabel) throws SQLException {
|
||||
return delegate.getNClob(columnLabel);
|
||||
}
|
||||
|
||||
@Override public SQLXML getSQLXML(int columnIndex) throws SQLException {
|
||||
return delegate.getSQLXML(columnIndex);
|
||||
}
|
||||
|
||||
@Override public SQLXML getSQLXML(String columnLabel) throws SQLException {
|
||||
return delegate.getSQLXML(columnLabel);
|
||||
}
|
||||
|
||||
@Override public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
|
||||
delegate.updateSQLXML(columnIndex, xmlObject);
|
||||
}
|
||||
|
||||
@Override public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
|
||||
delegate.updateSQLXML(columnLabel, xmlObject);
|
||||
}
|
||||
|
||||
@Override public String getNString(int columnIndex) throws SQLException {
|
||||
return delegate.getNString(columnIndex);
|
||||
}
|
||||
|
||||
@Override public String getNString(String columnLabel) throws SQLException {
|
||||
return delegate.getNString(columnLabel);
|
||||
}
|
||||
|
||||
@Override public Reader getNCharacterStream(int columnIndex) throws SQLException {
|
||||
return delegate.getNCharacterStream(columnIndex);
|
||||
}
|
||||
|
||||
@Override public Reader getNCharacterStream(String columnLabel) throws SQLException {
|
||||
return delegate.getNCharacterStream(columnLabel);
|
||||
}
|
||||
|
||||
@Override public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
|
||||
delegate.updateNCharacterStream(columnIndex, x, length);
|
||||
}
|
||||
|
||||
@Override public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
|
||||
delegate.updateNCharacterStream(columnLabel, reader, length);
|
||||
}
|
||||
|
||||
@Override public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
|
||||
delegate.updateAsciiStream(columnIndex, x, length);
|
||||
}
|
||||
|
||||
@Override public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
|
||||
delegate.updateBinaryStream(columnIndex, x, length);
|
||||
}
|
||||
|
||||
@Override public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
|
||||
delegate.updateCharacterStream(columnIndex, x, length);
|
||||
}
|
||||
|
||||
@Override public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
|
||||
delegate.updateAsciiStream(columnLabel, x, length);
|
||||
}
|
||||
|
||||
@Override public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
|
||||
delegate.updateBinaryStream(columnLabel, x, length);
|
||||
}
|
||||
|
||||
@Override public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
|
||||
delegate.updateCharacterStream(columnLabel, reader, length);
|
||||
}
|
||||
|
||||
@Override public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
|
||||
delegate.updateBlob(columnIndex, inputStream, length);
|
||||
}
|
||||
|
||||
@Override public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
|
||||
delegate.updateBlob(columnLabel, inputStream, length);
|
||||
}
|
||||
|
||||
@Override public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
|
||||
delegate.updateClob(columnIndex, reader, length);
|
||||
}
|
||||
|
||||
@Override public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
|
||||
delegate.updateClob(columnLabel, reader, length);
|
||||
}
|
||||
|
||||
@Override public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
|
||||
delegate.updateNClob(columnIndex, reader, length);
|
||||
}
|
||||
|
||||
@Override public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
|
||||
delegate.updateNClob(columnLabel, reader, length);
|
||||
}
|
||||
|
||||
@Override public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
|
||||
delegate.updateNCharacterStream(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
|
||||
delegate.updateNCharacterStream(columnLabel, reader);
|
||||
}
|
||||
|
||||
@Override public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
|
||||
delegate.updateAsciiStream(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
|
||||
delegate.updateBinaryStream(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
|
||||
delegate.updateCharacterStream(columnIndex, x);
|
||||
}
|
||||
|
||||
@Override public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
|
||||
delegate.updateAsciiStream(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
|
||||
delegate.updateBinaryStream(columnLabel, x);
|
||||
}
|
||||
|
||||
@Override public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
|
||||
delegate.updateCharacterStream(columnLabel, reader);
|
||||
}
|
||||
|
||||
@Override public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
|
||||
delegate.updateBlob(columnIndex, inputStream);
|
||||
}
|
||||
|
||||
@Override public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
|
||||
delegate.updateBlob(columnLabel, inputStream);
|
||||
}
|
||||
|
||||
@Override public void updateClob(int columnIndex, Reader reader) throws SQLException {
|
||||
delegate.updateClob(columnIndex, reader);
|
||||
}
|
||||
|
||||
@Override public void updateClob(String columnLabel, Reader reader) throws SQLException {
|
||||
delegate.updateClob(columnLabel, reader);
|
||||
}
|
||||
|
||||
@Override public void updateNClob(int columnIndex, Reader reader) throws SQLException {
|
||||
delegate.updateNClob(columnIndex, reader);
|
||||
}
|
||||
|
||||
@Override public void updateNClob(String columnLabel, Reader reader) throws SQLException {
|
||||
delegate.updateNClob(columnLabel, reader);
|
||||
}
|
||||
|
||||
@Override public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
|
||||
return delegate.getObject(columnIndex, type);
|
||||
}
|
||||
|
||||
@Override public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
|
||||
return delegate.getObject(columnLabel, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateObject(int columnIndex, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException {
|
||||
delegate.updateObject(columnIndex, x, targetSqlType, scaleOrLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateObject(String columnLabel, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException {
|
||||
delegate.updateObject(columnLabel, x, targetSqlType, scaleOrLength);
|
||||
}
|
||||
|
||||
@Override public void updateObject(int columnIndex, Object x, SQLType targetSqlType) throws SQLException {
|
||||
delegate.updateObject(columnIndex, x, targetSqlType);
|
||||
}
|
||||
|
||||
@Override public void updateObject(String columnLabel, Object x, SQLType targetSqlType) throws SQLException {
|
||||
delegate.updateObject(columnLabel, x, targetSqlType);
|
||||
}
|
||||
|
||||
@Override public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
return delegate.unwrap(iface);
|
||||
}
|
||||
|
||||
@Override public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||
return delegate.isWrapperFor(iface);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,135 @@
|
||||
package cn.axzo.msg.center.message.service.todo.mybatis.resultcount;
|
||||
|
||||
import cn.axzo.framework.rocketmq.utils.TraceUtils;
|
||||
import cn.axzo.msg.center.inside.notices.config.DiagnosisProps;
|
||||
import cn.axzo.msg.center.message.service.todo.mybatis.SQLAccessor;
|
||||
import cn.axzo.msg.center.utils.DingTaskMessageService;
|
||||
import cn.axzo.riven.client.common.enums.DingTalkMsgTypeEnum;
|
||||
import cn.axzo.riven.client.req.DingDingSendRebootGroupMsgReq;
|
||||
import cn.hutool.db.sql.StatementWrapper;
|
||||
import com.mysql.cj.jdbc.ClientPreparedStatement;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Slf4j
|
||||
class ProxyStatement extends StatementWrapper {
|
||||
|
||||
private static final AtomicLong ID_SEQ = new AtomicLong(0);
|
||||
private static final Executor EXECUTOR = new ThreadPoolExecutor(1, 3,
|
||||
1L, TimeUnit.MINUTES,
|
||||
new ArrayBlockingQueue<>(20));
|
||||
|
||||
private final long id = ID_SEQ.incrementAndGet();
|
||||
private final PreparedStatement rawStatement;
|
||||
private final DiagnosisProps props;
|
||||
private final ListableBeanFactory beanFactory;
|
||||
private final AtomicInteger resultCount = new AtomicInteger(0);
|
||||
private final AtomicBoolean isThresholdWarned = new AtomicBoolean(false);
|
||||
private final AtomicBoolean isCloseWarned = new AtomicBoolean(false);
|
||||
|
||||
private volatile String sql;
|
||||
|
||||
public ProxyStatement(PreparedStatement rawStatement,
|
||||
DiagnosisProps props,
|
||||
ListableBeanFactory beanFactory) {
|
||||
super(rawStatement);
|
||||
this.rawStatement = rawStatement;
|
||||
this.props = props;
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
void rowAdvanced() {
|
||||
int currentCount = resultCount.incrementAndGet();
|
||||
maybeWarn("Threshold", isThresholdWarned, currentCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet getResultSet() throws SQLException {
|
||||
ResultSet resultSet = super.getResultSet();
|
||||
return new ProxyResultSet(this, resultSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SQLException {
|
||||
super.close();
|
||||
maybeWarn("Close", isCloseWarned, resultCount.get());
|
||||
}
|
||||
|
||||
private void maybeWarn(String phase, AtomicBoolean warned, int currentCount) {
|
||||
if (currentCount < props.getSqlResultCountWarningThreshold()) return;
|
||||
if (!warned.compareAndSet(false, true)) return;
|
||||
try {
|
||||
if (sql == null)
|
||||
sql = determineSQL();
|
||||
EXECUTOR.execute(() -> {
|
||||
try {
|
||||
sendWarn(phase, currentCount, sql);
|
||||
} catch (Exception e) {
|
||||
log.warn("[Task] Error sending warning", e);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
log.warn("[Submit] Error sending warning", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendWarn(String phase, int currentCount, String sql) {
|
||||
DingTaskMessageService dingTaskMessageService = beanFactory
|
||||
.getBeanProvider(DingTaskMessageService.class).getIfAvailable();
|
||||
if (dingTaskMessageService == null) return;
|
||||
DingDingSendRebootGroupMsgReq req = new DingDingSendRebootGroupMsgReq();
|
||||
//消息类型
|
||||
req.setMsgType(DingTalkMsgTypeEnum.sampleMarkdown);
|
||||
//发送内容
|
||||
String title = "查询过多数据";
|
||||
String markdown = "## " + title + "\n" +
|
||||
"查询ID: " + id + "\n\n" +
|
||||
"环境: " + props.getActiveProfile() + "\n\n" +
|
||||
"TraceId: " + TraceUtils.getOrCreateTraceId() + "\n\n" +
|
||||
"阶段: " + phase + "\n\n" +
|
||||
"阈值数量: " + props.getSqlResultCountWarningThreshold() + "\n\n" +
|
||||
"当前数量: " + currentCount + "\n\n" +
|
||||
"SQL: " + sql + "\n";
|
||||
dingTaskMessageService.send(title, markdown);
|
||||
}
|
||||
|
||||
private String determineSQL() {
|
||||
String sql;
|
||||
try {
|
||||
sql = getSqlFromStmt();
|
||||
} catch (Exception e) {
|
||||
log.warn("[SQL] Error building sql", e);
|
||||
sql = getSampleSQL();
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
private String getSqlFromStmt() throws Exception {
|
||||
if (rawStatement instanceof com.zaxxer.hikari.pool.ProxyStatement) {
|
||||
Statement stmt = SQLAccessor.getStmtFromProxy((com.zaxxer.hikari.pool.ProxyStatement) rawStatement);
|
||||
if (stmt instanceof ClientPreparedStatement && !stmt.isClosed())
|
||||
return ((ClientPreparedStatement) stmt).asSql();
|
||||
}
|
||||
return getSampleSQL();
|
||||
}
|
||||
|
||||
private String getSampleSQL() {
|
||||
return StringUtils.substringAfter(rawStatement.toString(), ":");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package cn.axzo.msg.center.message.service.todo.mybatis.resultcount;
|
||||
|
||||
import cn.axzo.msg.center.inside.notices.config.DiagnosisProps;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.ibatis.executor.statement.StatementHandler;
|
||||
import org.apache.ibatis.plugin.Interceptor;
|
||||
import org.apache.ibatis.plugin.Intercepts;
|
||||
import org.apache.ibatis.plugin.Invocation;
|
||||
import org.apache.ibatis.plugin.Signature;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.Statement;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Intercepts({
|
||||
@Signature(type = StatementHandler.class, method = "prepare",
|
||||
args = {Connection.class, Integer.class})
|
||||
})
|
||||
@RequiredArgsConstructor
|
||||
public class ResultCountInterceptor implements Interceptor {
|
||||
|
||||
private final DiagnosisProps props;
|
||||
private final ListableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
Statement stmt = (Statement)invocation.proceed();
|
||||
if (!props.isEnableResultCountWarning()) return stmt;
|
||||
if (!(stmt instanceof PreparedStatement)) return stmt;
|
||||
return new ProxyStatement((PreparedStatement)stmt, props, beanFactory);
|
||||
}
|
||||
|
||||
}
|
||||
@ -44,7 +44,7 @@ public class NimPushService {
|
||||
|
||||
@Nullable
|
||||
public JSONObject buildPayload(PushMessage message, PushPeer peer) {
|
||||
if (cfg.getPushChannel() != PushChannel.NIM) return null;
|
||||
if (!cfg.isPushChannelEnabled(PushChannel.NIM)) return null;
|
||||
PushData pushData = message.getPushData();
|
||||
if (pushData == null || !pushData.isSwitchOn()) return null;
|
||||
PushContent content = new PushContent();
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package cn.axzo.msg.center.utils;
|
||||
|
||||
import cn.axzo.riven.client.common.enums.DingTalkMsgTypeEnum;
|
||||
import cn.axzo.riven.client.feign.DingDingMsgApi;
|
||||
import cn.axzo.riven.client.model.SampleMarkdown;
|
||||
import cn.axzo.riven.client.req.DingDingSendRebootGroupMsgReq;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class DingTaskMessageService {
|
||||
|
||||
private final DingDingMsgApi dingDingMsgApi;
|
||||
|
||||
public void send(String title, String markdown) {
|
||||
DingDingSendRebootGroupMsgReq req = new DingDingSendRebootGroupMsgReq();
|
||||
//消息类型
|
||||
req.setMsgType(DingTalkMsgTypeEnum.sampleMarkdown);
|
||||
req.setDingDingJson(new SampleMarkdown(title, markdown).toJson());
|
||||
//与nacos配置保持一致
|
||||
req.setDingDingScene("TODO_WARN");
|
||||
dingDingMsgApi.sendRebootGroupMsg(req);
|
||||
}
|
||||
|
||||
}
|
||||
@ -26,7 +26,8 @@ import org.springframework.core.env.Environment;
|
||||
"cn.axzo.basics.profiles.api",
|
||||
"cn.axzo.apollo.api",
|
||||
"cn.axzo.msg.center.inside.notices.service.impl",
|
||||
"cn.axzo.meepo.api"
|
||||
"cn.axzo.meepo.api",
|
||||
"cn.axzo.riven.client.feign"
|
||||
})
|
||||
/*@EnableAsync*/
|
||||
public class MsgCenterApplication {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user