应用启动后,第一次可以正常发送日志,再次发送时报如下异常:
20210816 16:02:09.339 [main] INFO org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver 58 - Exposing 1 endpoint(s) beneath base path '' 2021-08-16 16:02:09,478 main WARN SerializedLayout is deprecated due to the inherent security weakness in Java Serialization, see https://www.owasp.org/index.php/Deserialization_of_untrusted_data Consider using another layout, e.g. JsonLayout 20210816 16:02:09.495 [NettyClientSelector_1] INFO RocketmqRemoting 95 - closeChannel: close the connection to remote address[10.158.158.19:10911] result: true 2021-08-16 16:02:09,496 NettyClientSelector_1 ERROR Could not send message in RocketmqLog4j2Appender [rocketmqAppender].Message is : 2021-08-16 16:02:09,495 [INFO] RocketmqRemoting closeChannel: close the connection to remote address[10.158.158.19:10911] result: true org.apache.rocketmq.client.exception.MQClientException: The producer service state not OK, SHUTDOWN_ALREADY See http://rocketmq.apache.org/docs/faq/ for further details. at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.makeSureStateOK(DefaultMQProducerImpl.java:442) at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:560) at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendOneway(DefaultMQProducerImpl.java:1014) at org.apache.rocketmq.client.producer.DefaultMQProducer.sendOneway(DefaultMQProducer.java:403) at org.apache.rocketmq.logappender.log4j2.RocketmqLog4j2Appender.append(RocketmqLog4j2Appender.java:106) at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:156) at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:129) at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:120) at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)
原提问者GitHub用户JerryZ521
这个问题解决了。 原因描述:ProducerInstancer每次获取producer都是同一个实例,而我们的场景需要动态更新log4j2配置,重新初始化上下文时关闭了producer,现在改成每次获取新对象,stop方法改成每次调用关闭当前appender中的producer对象。
原回答者GitHub用户JerryZ521
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。