Repository navigation
Close the requester and temporary publisher when a send fails synchronously - #3789
Merged
artembilan merged 2 commits intoOct 28, 2026
Conversation
…nously `RabbitAmqpTemplate` closes the per-request `Requester` and, for a routing connection factory, the per-call `Publisher` only from the completion of the publish future. When message conversion or `publish()` throws, that future never completes and the client resources stay open on the connection. * Close the `Requester` and rethrow when `doSendAndReceive()` fails before the future exists * Close a temporary `Publisher` the same way in `doSend()` * Add `RabbitAmqpTemplateUnitTests` with mocked client resources Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
artembilan
requested changes
Oct 28, 2026
|
|
||
| @Test | ||
| void requesterIsClosedWhenPublishFails() { | ||
| AmqpConnectionFactory connectionFactory = mock(); |
Member
There was a problem hiding this comment.
OK. Stop it, please.
I think most of the cases really could be covered with real broker interaction.
We would need some mock for peculiar cases or unreachable API.
A request that cannot be converted must not leave the reply consumer attached. Verify this with a real broker in `RabbitAmqpTemplateTests` and keep the mock test only for the temporary publisher, which the broker does not expose. Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RabbitAmqpTemplatecloses the per-requestRequester(and, with aRoutingAmqpConnectionFactory, the per-callPublisher) only inwhenComplete()of the publish future, so when message conversion orpublish()throws synchronously the future never exists and the requester's reply queue, consumer and sender link stay open on the connection. This closes those resources on the synchronous failure path and rethrows.