rocketmq的優雅停機和 spring getBean 衝突
阿新 • • 發佈:2019-02-07
658648:2016-02-20 18:00:00,hostName=.com,node_error:e:org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'sactionManager': Singleton bean creation not allowed while the singletons of this factory are in destruction
(Do not request a bean from a BeanFactory in a destroy method implementation!),Flag=4e1c5cd12039c856755f3012
659044-org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'payTransactionManager': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
659337- at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:212)
659464- at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
659570- at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
659674- at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:400)
659799- at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:390)
659924- at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:226)
660036- at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:77)
660161- at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:54)
660286- at org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:245)
660422- at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100)
660533- at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
660643- at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
660736- at com.sun.proxy.$Proxy22.atomChangePayTradeSuccess(Unknown Source)
660805- at com. . . . .biz. .impl.PBizServiceImpl.onlinePayed(PayPayBizServiceImpl.java:293)
659044-org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'payTransactionManager': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
659337- at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:212)
659464- at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
659570- at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
659674- at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:400)
659799- at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:390)
659924- at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:226)
660036- at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:77)
660161- at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:54)
660286- at org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:245)
660422- at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100)
660533- at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
660643- at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
660736- at com.sun.proxy.$Proxy22.atomChangePayTradeSuccess(Unknown Source)
660805- at com. . . . .biz. .impl.PBizServiceImpl.onlinePayed(PayPayBizServiceImpl.java:293)
660925- at com. .CallBackNode.doService(PayCallBackNode.java:110)
原因解析:
代理類動態獲取bean,會有個判斷.
此時bean的記憶體關聯關係並沒有被銷燬. 入口沒關,程式碼依然可以執行.
*專案需求連結
線上問題, 每次重啟時,獲取bean時大量拋錯,具體為如下圖:
兩者存在競爭,需要在容器關閉之前關閉mq.
*概要設計
~涉及外部模組.
~各流程模組(主模組,子模組)互動圖
流程圖
類圖