启动应用程序中使用@serviceactivator在春季云流中
我将@serviceactivator录制为给Kafka错误的所有消息:
@ServiceActivator(inputChannel = "errorChannel")
public void handleErrors(final ErrorMessage in) {
log.error("encountered exception" + em.toString());
}
我还将ERRORCHANNELENABLED FLAG设置为true:
cloud:
stream:
function:
definition: consumeProfile
bindings:
#kafka producer
produceProfile-out-0:
binder: kafka
destination: profile
producer:
use-native-encoding: true
error-channel-enabled: true
问题是当我上传应用程序时,我将获得此错误日志:
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'profileListener.handleErrors.serviceActivator': Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:355) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:227) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1160) ~[spring-context-5.3.21.jar:5.3.21]
at org.springframework.integration.monitor.IntegrationMBeanExporter.enhanceHandlerMonitor(IntegrationMBeanExporter.java:865) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
at org.springframework.integration.monitor.IntegrationMBeanExporter.registerHandler(IntegrationMBeanExporter.java:695) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
at org.springframework.integration.monitor.IntegrationMBeanExporter.postProcessAbstractEndpoint(IntegrationMBeanExporter.java:340) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
at org.springframework.integration.monitor.IntegrationMBeanExporter.postProcessAfterInitialization(IntegrationMBeanExporter.java:324) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.postProcessMethodAndRegisterEndpointIfAny(MessagingAnnotationPostProcessor.java:257) ~[spring-integration-core-5.5.13.jar:5.5.13]
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.lambda$processAnnotationTypeOnMethod$1(MessagingAnnotationPostProcessor.java:215) ~[spring-integration-core-5.5.13.jar:5.5.13]
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na]
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.afterSingletonsInstantiated(MessagingAnnotationPostProcessor.java:136) ~[spring-integration-core-5.5.13.jar:5.5.13]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:974) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.21.jar:5.3.21]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.21.jar:5.3.21]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.1.jar:2.7.1]
at com.github.victorsilva95.pocspringcloudstreamkafka.PocSpringCloudStreamKafkaApplication.main(PocSpringCloudStreamKafkaApplication.java:14) ~[main/:na]
我的应用程序不会崩溃,因为例外,但我希望您的帮助理解原因,谢谢
I put @ServiceActivator to log all messages that gave error to kafka:
@ServiceActivator(inputChannel = "errorChannel")
public void handleErrors(final ErrorMessage in) {
log.error("encountered exception" + em.toString());
}
and I'm also setting the errorChannelEnabled flag to true:
cloud:
stream:
function:
definition: consumeProfile
bindings:
#kafka producer
produceProfile-out-0:
binder: kafka
destination: profile
producer:
use-native-encoding: true
error-channel-enabled: true
the problem is when I'm uploading the application I'm getting this error log:
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'profileListener.handleErrors.serviceActivator': Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:355) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:227) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1160) ~[spring-context-5.3.21.jar:5.3.21]
at org.springframework.integration.monitor.IntegrationMBeanExporter.enhanceHandlerMonitor(IntegrationMBeanExporter.java:865) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
at org.springframework.integration.monitor.IntegrationMBeanExporter.registerHandler(IntegrationMBeanExporter.java:695) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
at org.springframework.integration.monitor.IntegrationMBeanExporter.postProcessAbstractEndpoint(IntegrationMBeanExporter.java:340) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
at org.springframework.integration.monitor.IntegrationMBeanExporter.postProcessAfterInitialization(IntegrationMBeanExporter.java:324) ~[spring-integration-jmx-5.5.13.jar:5.5.13]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.postProcessMethodAndRegisterEndpointIfAny(MessagingAnnotationPostProcessor.java:257) ~[spring-integration-core-5.5.13.jar:5.5.13]
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.lambda$processAnnotationTypeOnMethod$1(MessagingAnnotationPostProcessor.java:215) ~[spring-integration-core-5.5.13.jar:5.5.13]
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na]
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.afterSingletonsInstantiated(MessagingAnnotationPostProcessor.java:136) ~[spring-integration-core-5.5.13.jar:5.5.13]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:974) ~[spring-beans-5.3.21.jar:5.3.21]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.21.jar:5.3.21]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.21.jar:5.3.21]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.1.jar:2.7.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.1.jar:2.7.1]
at com.github.victorsilva95.pocspringcloudstreamkafka.PocSpringCloudStreamKafkaApplication.main(PocSpringCloudStreamKafkaApplication.java:14) ~[main/:na]
my application does not crash because of this exception, but I wanted your help to understand the reason, thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谢谢您的样本。
这是
IntegrationMbeanexporter
中的错误:我们尝试在由MessagingAngingAndationPostProcessor
创建的那一刻提取端点bean。因此,请在春季整合项目中提出GH问题,我们将看到我们可以做什么。
同时,作为解决方法,您可以通过各自的SRPing引导属性关闭JMX:
Spring.jmx.enabled = false
。无论弹簧启动默认决策如何:Thank you for the sample.
This is a bug in the
IntegrationMBeanExporter
: we try to pull an endpoint bean at the moment it is created by theMessagingAnnotationPostProcessor
.So, please, raise a GH issue in the Spring Integration project and we will see what we can do.
Meanwhile as a workaround you can turn off JMX by respective Srping Boot property:
spring.jmx.enabled=false
. We have it auto-configured by default for Spring Integration regardless of Spring Boot default decision: