Skip to content

AmqpListener Circular Reference #3365

@cppwfs

Description

@cppwfs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions