-
Notifications
You must be signed in to change notification settings - Fork 646
AmqpListener Circular Reference #3365
Copy link
Copy link
Description
In what version(s) of Spring AMQP are you seeing this issue?
Spring AMQP: 4.1.0-SNAPSHOT
Spring Boot: 4.03
Description
When a method declaration is annotated with @AmqpListener and exists in the same Java Configuration class as the declaration for the AmqpMessageListenerContainerFactory, the application fails to start because of a circular reference as shown below.
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'amqpPocConfiguration': Requested bean is currently in creation: Is there an unresolvable circular reference or an asynchronous initialization dependency?
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:541) ~[spring-beans-7.0.5.jar:7.0.5]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:310) ~[spring-beans-7.0.5.jar:7.0.5]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:331) ~[spring-beans-7.0.5.jar:7.0.5]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) ~[spring-beans-7.0.5.jar:7.0.5]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:413) ~[spring-beans-7.0.5.jar:7.0.5]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1362) ~[spring-beans-7.0.5.jar:7.0.5]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1194) ~[spring-beans-7.0.5.jar:7.0.5]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:565) ~[spring-beans-7.0.5.jar:7.0.5]
Work Around
Declare the method that is annotated with @AmqpListener in another class that is annotated as a @Service.
Expected Behavior
That the method declaration that is annotated with the AmqpListener should be able to be in the same configuration as the declaration for AmqpMessageListenerContainerFactory.
Reactions are currently unavailable