Skip to content

Add ProtonDeliveryListener into spring-amqp-client#3287

Merged
cppwfs merged 2 commits intospring-projects:mainfrom
artembilan:proton_listener
Jan 14, 2026
Merged

Add ProtonDeliveryListener into spring-amqp-client#3287
cppwfs merged 2 commits intospring-projects:mainfrom
artembilan:proton_listener

Conversation

@artembilan
Copy link
Copy Markdown
Member

Sometimes target projects would like to deal with native ProtonJ API but still rely on the Spring flexibility with listener container infrastructure.

  • Add ProtonDeliveryListener to handle Delivery directly
  • Test and document the feature
  • Fix copy/paste artifact in the whats-new.adoc

Sometimes target projects would like to deal with native ProtonJ API
but still rely on the Spring flexibility with listener container infrastructure.

* Add `ProtonDeliveryListener` to handle `Delivery` directly
* Test and document the feature
* Fix copy/paste artifact in the `whats-new.adoc`
@artembilan artembilan added this to the 4.1.0-M1 milestone Jan 14, 2026
@artembilan artembilan requested a review from cppwfs January 14, 2026 14:13
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 add on feature!

Just my usual annoying comments.


=== ProtonJ `Delivery` Consumption

For convenience, a `ProtonDeliveryListener` contract is provided to handle a native ProtonJ `Delivery` objects instead of Spring AMQP messages.
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.

"handle a native ProtonJ Deliver objects " Remove the a since the syntax of the sentence deals with objects (plural)


For convenience, a `ProtonDeliveryListener` contract is provided to handle a native ProtonJ `Delivery` objects instead of Spring AMQP messages.
It could be useful in scenarios where full control over the `Delivery` instance is required.
For example, adding some reject conditions, handling received data as an `InputStream`, replenished link credits dynamically, according to some target application logic.
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.

replenished should be replenish

NOTE: The manual delivery settlement still can be skipped, if the `AmqpMessageListenerContainer` is configured for `autoAccept = true` (default).
And the `AmqpMessageListenerContainer` performs credits replenishment automatically.

The `ProtonDeliveryListener` implementation should be injected into the `AmqpMessageListenerContainer` as regular a `MessageListener`:
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 as regular a with as a regular.

* Therefore, the listener must manually acknowledge the message or reject/requeue, according to its logic.
* <p>
* If a {@link ProtonDeliveryListener} is provided and {@code autoAccept == false},
* it is this listener's responsibility to acknowledge the message manually and replenish the link credits.
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.

Maybe the the listener's instead this listener's. WDYT

}

if (this.autoAccept) {
replenishCreditOperation.run();
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.

Is it ok to replenish the credits after the onMessage for the non ProtonDeliveryListener path. Before we replenished the credits before the onMessage.

Just curious.

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.

Oh! I see your point.
Yes, I really meant it originally to replenish after the listener call.
So, let's treat this as a bug fix! 😄

Thank you!

@artembilan artembilan requested a review from cppwfs January 14, 2026 16:41
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!

Thanks for the updates!

@cppwfs cppwfs merged commit a65930b into spring-projects:main Jan 14, 2026
3 checks passed
@artembilan artembilan deleted the proton_listener branch January 15, 2026 15:54
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