惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
MyScale Blog
MyScale Blog
月光博客
月光博客
S
SegmentFault 最新的问题
C
CERT Recently Published Vulnerability Notes
P
Proofpoint News Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
人人都是产品经理
人人都是产品经理
K
Kaspersky official blog
Forbes - Security
Forbes - Security
宝玉的分享
宝玉的分享
爱范儿
爱范儿
V
Visual Studio Blog
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
The Cloudflare Blog
Attack and Defense Labs
Attack and Defense Labs
美团技术团队
L
LangChain Blog
NISL@THU
NISL@THU
IT之家
IT之家
T
Tor Project blog
云风的 BLOG
云风的 BLOG
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Cisco Talos Blog
Cisco Talos Blog
I
InfoQ
Help Net Security
Help Net Security
Engineering at Meta
Engineering at Meta
Know Your Adversary
Know Your Adversary
I
Intezer
Recent Commits to openclaw:main
Recent Commits to openclaw:main
TaoSecurity Blog
TaoSecurity Blog
P
Palo Alto Networks Blog
GbyAI
GbyAI
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - Franky
L
Lohrmann on Cybersecurity
The Register - Security
The Register - Security
W
WeLiveSecurity
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY

博客园 - Doyourself!

rocketmq 启动后 在mq console界面的consumer的Quantity数量显示为0 问题记录 python 切换版本后 提示 无法在python 3.11(.venv)(D:/my_rag_bot/.venv/Scripts/python.exe)设置 python sdk,该sdk似乎无效 记录一次日志告警随着nacos文件动态刷新而失效的问题 多个WebMvcConfigurer配置Jackson2ObjectMapperBuilder不生效问题记录 自定义拦截器不生效问题记录 记录一次nginx能通但是请求一直不了的问题 idea远程连接并本地打包到远程服务器 记一次生产环境内存溢出记录 凤凰架构总结 sentinel接入记录 JVM虚拟机总结 记录一次首页优化的经历 使用sharding-jdbc做分库分表记录 使用druid自定义拦截器 记录一次 maven 子模块相互依赖导致的父模块无法动态升级的问题 'parent.relativePath' points at wrong local POM 雪花算法snowflakeIdWorker使用记录 全局调用链路traceId网关到业务层、feign调用统一问题记录 Spring Cloud 的ribbon的饥饿加载机制 根据druid将慢sql通过钉钉的方式进行告警功能记录
打印mq异常消息记录
Doyourself! · 2023-08-25 · via 博客园 - Doyourself!

       mq的异常日志,发现在线上有大量的异常信息,但是钉钉告警里面却没有搜到,自己已经重写了logback的TurboFilter方法,仍然无法打印。最后发现原来是自己给过滤了。代码如下:

package com.gwm.marketing.filter.log;


@Component
public class MarketingLogFilter extends TurboFilter {

    /**rocketmq异常信息打印*/
    private static final String ROCKETMQ_ERROR = "rocketmq";

    @Resource
    private SimpleBufferTriggerUtils simpleBufferTriggerUtils;

    @Resource
    private OptionalAlarmUriUtils optionalAlarmUriUtils;
    @Override
    public FilterReply decide(Marker marker, Logger logger, Level level, String s, Object[] objects, Throwable throwable) {
        if(logger.getName().contains("rocketmq")){
            System.out.println("mq error:" + (Optional.of(logger).map(l->l.getName()).orElse(null))+ ",throwable:" + Optional.ofNullable(throwable).map(t->t.getMessage()).orElse(null));
        }
        //todo 如果是非运行时异常 发送钉钉告警。排除运行时异常
        if(throwable != null && StringUtils.isNotEmpty(throwable.getMessage()) && level.equals(Level.ERROR)){
            if(optionalAlarmUriUtils == null){
                optionalAlarmUriUtils = ApplicationContext.getBean(OptionalAlarmUriUtils.class);
            }
            if(!optionalAlarmUriUtils.isExistUri(logger.getName())){
                if(simpleBufferTriggerUtils == null){
                    simpleBufferTriggerUtils =  ApplicationContext.getBean(SimpleBufferTriggerUtils.class);
                }
                simpleBufferTriggerUtils.proceErrorAlarm(Tag.builder().applicationName(DingdingAlarmUtil.applicationName)
                        .env(DingdingAlarmUtil.env)
                        .ip(IpUtil.initIp())
                        .traceId(MDC.get("traceId"))
                        .requestUri(logger.getName())
                        .exMessage(JSONObject.toJSON(throwable.getMessage().length() >500 ?
                                throwable.getMessage().substring(0,500).toString():throwable.getMessage()).toString())
                        .build());
            }
        }else if(Level.ERROR.equals(level) && logger.getName().contains(ROCKETMQ_ERROR)){
            //如果是mq的异常 也要进行告警
            if(!optionalAlarmUriUtils.isExistUri(logger.getName())){
                String exMessage = Optional.ofNullable(s).orElse("") + Optional.ofNullable(objects).map(t->t[0]).orElse(null);
                simpleBufferTriggerUtils.proceErrorAlarm(Tag.builder().applicationName(DingdingAlarmUtil.applicationName)
                        .env(DingdingAlarmUtil.env).ip(IpUtil.initIp()).requestUri(logger.getName()).traceId(MDC.get("traceId"))
                        .exMessage(Optional.ofNullable(exMessage).map(t->t.length()>500?t.substring(0,500):t).orElse(""))
                        .build());
            }
        }
        //todo 如果接入kafka,则此处需要需要改为NEUTRAL,以防止kakfa的多次打印
        return FilterReply.NEUTRAL;
    }
}

    本地调试时候发现,在mq异常时候 其throwable是空的。而自己刚好判断时候有写,如果为空的话,不会进行打印,所以导致打印不出来了。