Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-2572 Treat ConfirmType.SIMPLE same as ConfirmType.CORRELATED #2717

Merged
merged 4 commits into from
May 31, 2024

Conversation

bjoernhaeuser
Copy link
Contributor

@bjoernhaeuser bjoernhaeuser commented May 21, 2024

GH-2572 Do not close channel when ConfirmType.SIMPLE is used for publisher confirmations.

See #2571 (discussion) and #2572 (issue) for reference.

@@ -2344,9 +2344,6 @@ public <T> T invoke(OperationsCallback<T> action, @Nullable com.rabbitmq.client.
if (channel == null) {
throw new IllegalStateException("Connection returned a null channel");
}
if (!connectionFactory.isPublisherConfirms()) {
Copy link
Member

Choose a reason for hiding this comment

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

Why remove altogether?
The discussion was about condition improvement:

if (!connectionFactory.isPublisherConfirms() && !connectionFactory.isSimplePublisherConfirms()) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking the time to review this!

I went through the discussion and thought the code and came to (maybe faulty) conclusion that closing the channel never makes sense for the invoke method. Especially for me this totally unexpected and not mentioned in the docs anywhere.

Please let me know which way you would like to see this proceed!

Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

I believe the close is not required when we are in publish-confirm mode.
Therefore that condition and another PR.
Sorry, I don't see anywhere in discussion that we were going to remove this condition altogether.

@artembilan
Copy link
Member

The other fix feel like more legit: #2651.
WDYT?

@@ -2344,7 +2344,7 @@ public <T> T invoke(OperationsCallback<T> action, @Nullable com.rabbitmq.client.
if (channel == null) {
throw new IllegalStateException("Connection returned a null channel");
}
if (!connectionFactory.isPublisherConfirms()) {
if (!connectionFactory.isPublisherConfirms() && !connectionFactory.isSimplePublisherConfirms()) {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the change in #2651 more precise and accurate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, this was still a bit WIP. Added this change here as well and added also test for this. Hope this covers this completely.

@bjoernhaeuser bjoernhaeuser force-pushed the main branch 3 times, most recently from 6dbdd48 to 638ff76 Compare May 31, 2024 17:35
@bjoernhaeuser bjoernhaeuser changed the title GH-2572 Do not close channel during invoke call GH-2572 Treat ConfirmType.SIMPLE same as ConfirmType.CORRELATED May 31, 2024
Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

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

Looks like there is failing existing test since we have changed condition, I guess:

RabbitTemplateTests > testPublisherConnWithInvokeAndSimpleConfirmations() FAILED
    org.opentest4j.AssertionFailedError: 
    Expecting value to be false but was true
        at app//org.springframework.amqp.rabbit.core.RabbitTemplateTests.testPublisherConnWithInvokeAndSimpleConfirmations(RabbitTemplateTests.java:631)

@bjoernhaeuser
Copy link
Contributor Author

Looks like there is failing existing test since we have changed condition, I guess:

RabbitTemplateTests > testPublisherConnWithInvokeAndSimpleConfirmations() FAILED
    org.opentest4j.AssertionFailedError: 
    Expecting value to be false but was true
        at app//org.springframework.amqp.rabbit.core.RabbitTemplateTests.testPublisherConnWithInvokeAndSimpleConfirmations(RabbitTemplateTests.java:631)

Yeah, thanks! This test does not make sense anymore, removed it :)

@artembilan artembilan merged commit 556dda5 into spring-projects:main May 31, 2024
3 checks passed
@artembilan
Copy link
Member

I had to revert the fix to our original discussion: 2bb4f29.
Apparently there are use-cases when listener is added to the PublisherCallbackChannel which makes sense only for the ConfirmType.CORRELATED mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants