Skip to content

Document @AmqpListener#3364

Merged
cppwfs merged 2 commits intospring-projects:mainfrom
artembilan:AmqpListener_docs
Mar 3, 2026
Merged

Document @AmqpListener#3364
cppwfs merged 2 commits intospring-projects:mainfrom
artembilan:AmqpListener_docs

Conversation

@artembilan
Copy link
Copy Markdown
Member

  • Fix MethodAmqpListenerEndpoint for a proper .listenerContainer suffix. We really register an AmqpMessageListenerContainer instance

* Fix `MethodAmqpListenerEndpoint` for a proper `.listenerContainer` suffix.
We really register an `AmqpMessageListenerContainer` instance
@artembilan artembilan added this to the 4.1.0-M3 milestone Mar 2, 2026
@artembilan artembilan requested a review from cppwfs March 2, 2026 19:20
Copy link
Copy Markdown
Contributor

@cppwfs cppwfs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs and changes look good.

Just a couple of notes.


* The `org.apache.qpid.protonj2.client.Client` where its `org.apache.qpid.protonj2.client.ClientOptions` property is based on the respective attributes of the imported metadata from the `@EnableAmqp`.
* The `AmqpListenerEndpointRegistry` - the global component to register AMQP listener containers programmatically.
* The `AmqpListenerAnnotationBeanPostProcessor` - a `BeanPostProcessor` to parse POJO methods with the `@AmqpListener` and register listener containers with via the `AmqpListenerEndpointRegistry`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

containers with via replace with containers via


=== `@AmqpListener`

For high-level and convenient configuration, the framework provides an `@AmqpListener` annotation to mark POJO methods to be used as listener invokers from created by the framework `AmqpMessageListenerContainer` instances.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace invokers from created by with invoker created by

The `id` attribute is not required, and target listener container bean name will be based on the class name, method name plus `.listenerContainer` suffix.
The `addresses` - can be an array of names, or each item can be a comma-delimited set of names.
This can be useful when a list of AMQP addresses is provided via external configuration properties.
The `containerFactory` (see below), `executor`, `messageConverter` and `headerMapper` attributes are options and can be configured to bean name of bean reference as a SpEL expression like the `executor` in the sample above.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"are options and can be configured to bean name of bean reference". Did you mean "are optional and can be configured to a bean name or a bean reference".

Unlike with the `@RabbitListener` and `RabbitListenerEndpointRegistry` infrastructure, the `AmqpListenerEndpointRegistry` uses an `AmqpMessageListenerContainerFactory` & `AmqpListenerEndpoint` to created an `AmqpMessageListenerContainer` instance, and registers it as a singleton bean into the application context directly.
The bean name for this `AmqpMessageListenerContainer` instance is a value from the `AmqpListenerEndpoint.getId()` or generated one based on the `MessageListener` class name and `.listenerContainer` suffix.

See `AmqpListenerEndpoint`, `AmqpMessageListenerContainerFactory` and `AmqpListenerEndpointRegistry` Javadocs for more information. No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing blank line.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean here since GH does not complain that we don't have an end of file: https://imgur.com/a/GnmOU8q
This article discuss it in more details: https://www.reddit.com/r/learnprogramming/comments/t7qofi/why_does_github_care_if_a_file_doesnt_have_a/.

I think the problem is more about new line symbol (line break) in the end of current last line, but really not a new line: https://www.pcmag.com/encyclopedia/term/line-break.
The easiest way for us to put it there is to press Enter key, and that creates a new blank line indeed 😄

The framework relies on a bean for this factory when `@AmqpListener` annotation is parsed via `AmqpListenerAnnotationBeanPostProcessor`.
If `@AmqpListener(containerFactory)` attribute is not provided on a POJO method, the framework expects a global bean for an `AmqpMessageListenerContainerFactory` with the `AmqpDefaultConfiguration.DEFAULT_AMQP_LISTENER_CONTAINER_FACTORY_BEAN_NAME`.

Unlike with the `@RabbitListener` and `RabbitListenerEndpointRegistry` infrastructure, the `AmqpListenerEndpointRegistry` uses an `AmqpMessageListenerContainerFactory` & `AmqpListenerEndpoint` to created an `AmqpMessageListenerContainer` instance, and registers it as a singleton bean into the application context directly.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to created an AmqpMessageListenerContainer instance should be to create an AmqpMessageListenerContainer instance

@artembilan artembilan requested a review from cppwfs March 3, 2026 11:35
Copy link
Copy Markdown
Contributor

@cppwfs cppwfs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Great Docs!

@cppwfs cppwfs merged commit b8974e7 into spring-projects:main Mar 3, 2026
3 checks passed
@artembilan artembilan deleted the AmqpListener_docs branch March 4, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants