Skip to content

Add AmqpMessagingListenerAdapter for AMQP 1.0 Client#3325

Merged
cppwfs merged 2 commits intospring-projects:mainfrom
artembilan:AmqpMessagingListenerAdapter
Feb 6, 2026
Merged

Add AmqpMessagingListenerAdapter for AMQP 1.0 Client#3325
cppwfs merged 2 commits intospring-projects:mainfrom
artembilan:AmqpMessagingListenerAdapter

Conversation

@artembilan
Copy link
Copy Markdown
Member

  • Add throws Exception to the ProtonDeliveryListener.onDelivery() contract to avoid any possible misleading transformations in the implementation
  • Add AcknowledgingProtonDeliveryListener contract as an extension of the ProtonDeliveryListener.
    Enforce its logic to a new contract with an AmqpAcknowledgment argument populated by the AmqpMessageListenerContainer.
    Such a contract is necessary to properly delegate replenish link credits logic back to the listener container.
    This logic is now included in the AmqpMessageListenerContainer.doInvokeListener() method. Either way, the target implementation is till free to deal with Delivery whatever is possible. However, there is a possibility of inconsistency when the container is paused, but listener calls addCredit() on the delivery's receiver
  • Add HandlerAdapter.getMethod() to avoid extra method parameter propagation to consumers of the HandlerAdapter
  • Extract record ReplyExpressionRoot from the AbstractAdaptableMessageListener to make it available for any other not RabbitMQ-based modules
  • Implement AmqpMessagingListenerAdapter for AMQP 1.0 client. It is similar to the MessagingMessageListenerAdapter for RabbitMQ-based modules, and is going to be used for POJO-based event-driven message handling, e.g. future @AmqpListener. A lot of AmqpMessagingListenerAdapter logic is really a copy/paste from the MessagingMessageListenerAdapter and its super class

* Add `throws Exception` to the `ProtonDeliveryListener.onDelivery()`
contract to avoid any possible misleading transformations in the implementation
* Add `AcknowledgingProtonDeliveryListener` contract as an extension of the
`ProtonDeliveryListener`.
Enforce its logic to a new contract with an `AmqpAcknowledgment` argument
populated by the `AmqpMessageListenerContainer`.
Such a contract is necessary to properly delegate replenish link credits logic back
to the listener container.
This logic is now included in the `AmqpMessageListenerContainer.doInvokeListener()` method.
Either way, the target implementation is till free to deal with `Delivery` whatever is possible.
However, there is a possibility of inconsistency when the container is paused, but
listener calls `addCredit()` on the delivery's receiver
* Add `HandlerAdapter.getMethod()` to avoid extra method parameter propagation to consumers of
the `HandlerAdapter`
* Extract `record ReplyExpressionRoot` from the `AbstractAdaptableMessageListener`
to make it available for any other not RabbitMQ-based modules
* Implement `AmqpMessagingListenerAdapter` for AMQP 1.0 client.
It is similar to the `MessagingMessageListenerAdapter` for RabbitMQ-based modules,
and is going to be used for POJO-based event-driven message handling, e.g. future `@AmqpListener`.
A lot of `AmqpMessagingListenerAdapter` logic is really a copy/paste
from the `MessagingMessageListenerAdapter` and its super class
@artembilan artembilan added this to the 4.1.0-M2 milestone Feb 6, 2026
@artembilan artembilan requested a review from cppwfs February 6, 2026 00:20
@artembilan
Copy link
Copy Markdown
Member Author

This is like a foundation for the @AmqpListener.
Fully similar in logic for the MessagingMessageListenerAdapter counterpart for the @RabbitListener.

The logic mostly copied from the MessagingMessageListenerAdapter: it is sometimes easier to copy/paste and have freedom to change any way you need rather than trying to extract super class with some awkward API to support all the possible variants.

There are no tests in this PR for new AmqpMessagingListenerAdapter class, since all of its functionality is going to be covered with integration tests from top-level configuration for @AmqpListener, including Mono-based method and Kotlin suspend functions.

Thanks

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.

Looks great!

Just a couple of comments.

* Fix typos in the `AmqpListenerErrorHandler` & `AmqpMessagingListenerAdapter` Javadocs
* Remove redundant `@Nullable` from `AmqpMessagingListenerAdapter`'s
`setErrorHandler()`, `setMessageConverter()` and `setBeanResolver()`
* Remove `projectionUsed` property logic from the `AmqpMessagingListenerAdapter.invokeHandlerAndProcessResult()`
as it looks like that message property is out of use anywhere in the project
@artembilan artembilan requested a review from cppwfs February 6, 2026 15:04
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.

Nice work on this!

LGTM!

@cppwfs cppwfs merged commit ef6aa26 into spring-projects:main Feb 6, 2026
3 checks passed
@artembilan artembilan deleted the AmqpMessagingListenerAdapter branch February 25, 2026 15:00
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